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

How to detect players?

Asked by 10 years ago

How would I go about detecting players when they are in the game or join a game.

0
Next time you ask a question like this, tell us what you have tried already and what doesn't work. If you'd looked at the Players API on the Wiki then you wouldn't need to ask this question. duckwit 1404 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

To check if they are in the game:

if game.Players:FindFirstChild("Altlightpower26") then
    print("Altlightpower26 is in the game")
else
    print("Altlightpower26 is not in the game")
end

When a player joins and leaves

--Joins
game.Players.PlayerAdded:connect(function(Player)
    print(Player.Name.." has entered")
end)

--Leaves
game.Players.PlayerRemoving:connect(function(Player)
    print(Player.Name.." is leaving the game")
end)
Ad

Answer this question