Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont my music stopper work? (Unfinished answer!)

the output keeps saying Workspace.Part.Script:13: 'then' expected near '=' and i dont understand it. and im wondering if this their is a more efficient way

if game.Workspace.Timber:IsPlaying() = true then 
	
game.Workspace.NewStyle:Stop()	
	
end

if game.Workspace.Timber:IsPlaying() = true then 
	
game.Workspace.Self:Stop()	
	
end

3 comments

0

Same output is Workspace.Part.S1:12: attempt to call method 'IsPlaying' (a boolean value)

0

How about instead of using a Colon ':' for the 'Timber:IsPlaying()', use a dot '.' instead 'Timber.IsPlaying == true then'. Hope this helped! :)

0

okay whoever disliked is a troll :L

2 answers

The :IsPlaying() method is more then likely recommended for sounds that are playing in the playergui.

It does not always work as planned when your using it as a global script since someone can join the game when the song was playing, and the song would still be playing for them, while everyone else has to wait until the recently joined players song finishes.

The only workaround is to play the sound in the players playergui, or to do it the ugly way is to make the script wait the length of the sound, stop it, and play the next one.

Just remember to put a message saying that if you recently joined, the first song you hear might be cut off early.

If you are not preloading your assets, It would be great to at up to 10 seconds before stopping and going to the next, since Roblox hasn't loaded the song to the client yet.

This should fix it.

if game.Workspace.Timber:IsPlaying() == true then

This is because you are checking if they are equal.(compares them not setting to a variable) As far as I know all if statements require a '=='

3 comments

0

OOOH! DUH! THANKS :D

0

But its still letting the other songs play while that one is :L

0

Posted ugly hax.

This discussion is preserved as it was. New answers, comments, and votes are closed.