Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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!

2 comments

0

can I add onto the function for it to add/destroy a variable in a table

0

Yes you can, here is example based off of Saver's code https://pastebin.com/XbMYfLzJ

This discussion is preserved as it was. New answers, comments, and votes are closed.