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

How do I make a song play when I spawn?

I have a script that only plays the first time I join, when I respawn it dosen't work.

SERVER SCRIPT

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		game.ReplicatedStorage.LobbySongEvent:FireClient(player)
	end)
end)

LOCAL SCRIPT

game.ReplicatedStorage.LobbySongEvent.OnClientEvent:Connect(function(player)
	game.Players.LocalPlayer.PlayerGui:WaitForChild("GameSound"):Pause()
	game.Players.LocalPlayer.PlayerGui:WaitForChild("LobbySound"):Resume()
end)

1 answer

✓ Accepted answer

It only runs when you rejoin or just join the server which is why it's an event. To prevent this, place an audio in workspace, and have a LocalScript in StarterGui and it'll look like this..

This will play locally still

local sound = workspace:WaitForChild("Sound")
sound.Playing = true

1 comment

0

I tried it and it worked! Thanks!

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