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

Is waiting on events a thing?

Asked by 7 years ago

So, I discovered that you could do something like this:

game.Players.LocalPlayer.Character.Humanoid.Died:wait()

So, does that basically wait until the character dies?

1 answer

Log in to vote
2
Answered by 7 years ago
Edited 7 years ago

Yes, using :Wait() after an event instead of :Connect() will wait for the event to fire.

--// Example
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local humanoid = char:WaitForChild("Humanoid")

        humanoid.Died:Wait()
        print(plr.Name.." Died!")

    end)
end)
0
Okay, awesome! Thanks, I really needed to know that worked for sure. xXLegendarySoldierXx 129 — 7y
1
And returns any arguments that event give ;) User#5423 17 — 7y
Ad

Answer this question