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

How do i make the Playeradded Event runs only 1 time?[Solved]

Asked by
Xianon 105
10 years ago

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?

0
I'm confused. So you want it to activate only when the first person enters? Tempestatem 884 — 10y
0
Exatcly! Xianon 105 — 10y
0
Well too late for me to try to post anything Tempestatem 884 — 10y

1 answer

Log in to vote
4
Answered by 10 years ago

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)
0
Thanks, It worked. Xianon 105 — 10y
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! adark 5487 — 10y
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. Articulating 1335 — 10y
Ad

Answer this question