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

How do I make a song play when I spawn?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by
0_2k 496 Moderation Voter
4 years ago

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
0
I tried it and it worked! Thanks! robertandre 35 — 4y
Ad

Answer this question