Discord
Login
Community
DARK THEME

myMusic.stop() is not a function


update = function()
  
  if keyboard.A then
    start = 1
  end
  
  if keyboard.S then
    start = 0
  end
  
  if start == 1 then
    myMusic = audio.playMusic("music")
  end
  
  if start == 0 then
    myMusic.stop()
  end
  
end

The console says myMusic.stop() is not a function but the code works anyway

I think you forgot to initialize start to something other than 0 or 1 ; when update() first run, start is equal to zero but myMusic is not defined yet.

So I would add:

init = function()
  start = -1
end

Thanks!

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community