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

How can I make a song play and when someone clicks "Play Game" it stops?

I'm interested in making that for my games. So for example I use an id say for example: 190789505 Would I be able to make it play and when the user clicks play game it will stop the music?

2 answers

This isn't a request but I'll provide you a link to guide you

Sound

2 comments

0

This is true. Still, please see my answer.

0

This wasn't helpful at all

To do this you will need to add a script/localscript under the button.

You will use Music:Play(), to play it, and Music:Stop(), to stop it. By the way, I will do the script for you, but do NOT request us to do a script for you. Please show us your current attempt. If you want to request go on the forums.

You need to use Events to get the click, in this case, MouseButton1Click, since it works better. Then, you connect it to a function, in wich we will make a new one.

music = script.Parent.Parent.Music -- Make sure the Sound is named Music and is parented above the button
music:Play() -- Make it play
script.Parent.MouseButton1Click:connect(function()
	music:Stop() -- Stop it on click
end)

Hope this works it out!

2 comments

0

That would work, but local sound would work so the music stops for that player, and not for all players

0

If the music is parented to player gui it is automatically local. Thus why I tell parent it after button

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