I'm making a little project that activates when a player joins, the problem is that when another player joins the script runs double and the device goes bad, How can i make the event only run once?
✓ ANSWER ACCEPTED
How do i make the Playeradded Event runs only 1 time?[Solved]
1 answer
✓ Accepted answer
Use
Game.Players.PlayerAdded:wait()
This waits for the PlayerAdded event to fire, then continues with the script. Alternatively, if you need to use the Player use the following:
local connection = "Connection"
connection = Game.Players.PlayerAdded:connect(function(Player)
connection:disconnect()
end)
3 comments
0
Thanks, It worked.
0
I'd like to point out that the first line in the second block is unneccesary, so don't think you have to include it!
0
No, it is necessary. If you try to assign a connection to a nil variable, which would occur without the first line, then your script will error.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
I'm confused. So you want it to activate only when the first person enters?
Exatcly!
Well too late for me to try to post anything