Ad
Log in to vote
0

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

Asked by 8 days 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 8 days 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 — 8d
0
Yes you can, here is example based off of Saver's code https://pastebin.com/XbMYfLzJ imKirda 2679 — 8d
Ad

Answer this question