So I want to add a song that plays only for the new player that enters the game, for about 42 seconds, which is how long the introduction GUI for the game is. I have the song already, but how should I do the script?
✓ ANSWER ACCEPTED
A song plays for a player while the introduction screen appears when player enters?
3 answers
✓ Accepted answer
local time = 42 --How long you want it to play
Game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local song = Workspace.Song
local clone = song:Clone()
clone.Parent = plr --This makes the sound play locally inside of the player.
clone:Play()
wait(time)
repeat
wait()
clone:Stop()
until clone.IsPlaying == false --This makes sure the sound stops, roblox's sound system is a bit messed up (as of, last time I checked)
end)
end)
local song = Workspace.Music --Put this to wherever your song file is.
song:Play() --Use the play function to start the song.
wait(42) --You can change this to a little more or a little less depending on how it works with your intro.
song:Stop() --Stops the music with the Stop function.
Hope this helps! :)
2 comments
1
I want it to only play the song for that player that enters though. I don't want it to play for the whole server. Do you have any idea on doing that?
0
I would insert the song into the player's head who entered. Then, I would use the script above.
local song = Workspace.Music --Put this to wherever your song file is.
game.Players.PlayerAdded:connect(function()
wait()
song:Play() --Use the play function to start the song.
wait(42) --You can change this to a little more or a little less depending on how it works with your intro.
song:Stop() --Stops the music with the Stop function.
end --You may need more ends
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Thanks so much! Worked Perfectly. But do you have any idea on lowering the volume of the song until you can't hear it anymore?
Sounds have a property called 'Volume' 1 is basically the max volume an d0 is mute so lowering it in increments of 0.1 would be most effective. Use a loop to lower the volume gradually.