Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Playing Sound for one player?

Asked by 8 years ago

When game runs sound plays normally, but when you click button it doesn't stop

01game.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.MouseButton1Click:connect(function()
13            local stopsound = plr.PlayerGui:FindFirstChild('Sound')
14 
15            if stopsound then
View all 21 lines...

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
8 years ago
Edited 8 years ago

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)

Ad

Answer this question