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

Efficient way to start a game?

Asked by
NecoBoss 194
9 years ago

Okay so currently I put a wait time for my scripts to begin after the game starts but I know other people do it differently. I looked it up and I think waitforchild is what I need. How would I use that in order to make sure my scripts don't run before the first player too join a server spawns?

0
The last major thing to load in a Player is the Character (player.Character), so you need to use either WaitForChild or FindFirstChild to check if the player is alive and make sure the code doesen't run if it's not. drew1017 330 — 9y

1 answer

Log in to vote
0
Answered by
cuff5 10
9 years ago

I think this is what you're talking about:

for i,v in pairs (game.Players:GetPlayers()) do
            name = v.Name
            check = game.Workspace:FindFirstChild(name)
            if check then
                checkHumanoid = check:FindFirstChild("Humanoid")
                if checkHumanoid then
                    --Start Your Game
                    end
                end 
            end
        end
Ad

Answer this question