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 the Playeradded Event runs only 1 time?[Solved]

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?

3 comments

0

I'm confused. So you want it to activate only when the first person enters?

0

Exatcly!

0

Well too late for me to try to post anything

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.