Hello scripters, I'm making a game and theres a song, when a player joins the music starts (if its a new server) and if player one is already 30 sec in the game and a other player joins the music is already 30 seconds far, but I need that player one is still 30 sec and the new player that it begins for him and contunues for player one. what did I do wrong (the song is 108 seconds long) and one thing every 108 seconds later the song got to replay (for the player for who's song is done)
wait (5) local sound = game.Workspace.LobbySound local sound:play() wait (108) repeat
I hope you can help me, thanks, bye!
-Gamer_io
You need to play the sound locally inside the player upon joining :)
Use a PlayerAdded
event, and wait for the Character to load. Then clone the sound into their PlayerGui, and play it.
local sound = workspace.LobbySound; --This is the sound sound.Looped = true; --Make sure it loops game.Players.PlayerAdded:Connect(function(plr) --PlayerAdded event local plrUI = plr:WaitForChild("PlayerGui"); --Get their PlayerGui plr.CharacterAdded:Wait(); --Wait for them to spawn local s = sound:Clone(); --Clone the sound s.Parent = plrUI; --Parent it to their PlayerGui s:Play(); --Play the cloned sound end)
Do this in a LocalScript. If this is a regular script, you are playing the same sound to every player. Store the sound within StarterPlayer so everyone starts with their own copy.
As far as the sound looping, if you only need it to play upon entering, I would just destroy the script and sound after waiting.
wait(108) sound:Destroy() script:Destroy()