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?
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! :)
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