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

How can I make this sound on join script work without lag?

Asked by 10 years ago

So this is the script I currently use to make a sound play when a player joins the game:

game.Players.PlayerAdded:connect(function(player)
    repeat wait() until player:findFirstChild("PlayerGui") -- Waits for PlayerGui to load
    player.PlayerGui.Sound:Play(Intro)
end)

And it worked fine. However, after I built my game, the sound now takes 10-15 seconds to play. I think it is because of line 2 where it waits for the player gui. Is there a way I can make it play, for only the player who joins, as soon as they join, without the lag?

1 answer

Log in to vote
0
Answered by 10 years ago

Try putting line 3 before line 2? Or you can make a separate script for the sound or GUI.

Ad

Answer this question