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

Playing Sound for one player?

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

game.Players.PlayerAdded:connect(function(plr)
	
	
			local startsound = plr.PlayerGui:FindFirstChild('Sound')
			
			if startsound then
				if startsound.Name == "BackgroundMusic" then
					startsound:Play()
				end
			end
					
		game.StarterGui.ScreenGui.StartFrame.PlayButton.MouseButton1Click:connect(function()
			local stopsound = plr.PlayerGui:FindFirstChild('Sound')
			
			if stopsound then
				if stopsound.Name == "BackgroundMusic" then
					stopsound:Stop()
				end
			end
		end)
end)

1 answer

✓ Accepted answer

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)

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