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

how do I make it detect if someone joins the game?

Asked by 3 years ago

I want to make it so if someone joins the game it will detect that they joined the game and then it will make a new variable in a table? and when someone leaves the game their variable gets deleted?

1 answer

Log in to vote
1
Answered by 3 years ago

You can use Players.PlayersAdded and Players.PlayerRemoving

Example:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    print(player.Name .. " joined the game!")
end)

Players.PlayerRemoving:Connect(function(player)
    print(player.Name .. " left the game!")
end)

Hope it help!

0
can I add onto the function for it to add/destroy a variable in a table Greninja90290 4 — 3y
0
Yes you can, here is example based off of Saver's code https://pastebin.com/XbMYfLzJ imKirda 4491 — 3y
Ad

Answer this question