When game runs sound plays normally, but when you click button it doesn't stop
01 | game.Players.PlayerAdded:connect( function (plr) |
02 |
03 |
04 | local startsound = plr.PlayerGui:FindFirstChild( 'Sound' ) |
05 |
06 | if startsound then |
07 | if startsound.Name = = "BackgroundMusic" then |
08 | startsound:Play() |
09 | end |
10 | end |
11 |
12 | game.StarterGui.ScreenGui.StartFrame.PlayButton.MouseButton 1 Click:connect( function () |
13 | local stopsound = plr.PlayerGui:FindFirstChild( 'Sound' ) |
14 |
15 | if stopsound then |
You bind the click function to the StarterGui*. You should use the plr.PlayerGui
instead.
*StarterGui is the service that clones all instance inside of it, to the players PlayerGui
when their character gets added. (On entering the game, or respawning)