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

How fast does a script run [Read Description]? Round Script PlayerAdded:Disconnect()

Asked by 3 years ago

to be specific

I have a PlayerAdded Event that I constantly disconnect when my round script changes rounds

so basically the playeradded event switches on and off every time each having different things

The problem here was that

if there ever was a possibility of a player joining while the PlayerAdded disconnected and a new playeradded was made

then the game would break

the code runs like this basically


If Round.Value == 'Begin' then local NewEvent = game.Players.PlayerAdded:Connect() end) -- What if a player joins somewhere here -- And Is it possible? NewEvent:Disconnect() end
0
Instead of a PlayerAdded event, you could use a for loop to check if each player is setup correctly / has everything they need to have. appxritixn 2235 — 3y
0
What if they join during mid round Overseer_Prince 188 — 3y
1
You should only disconnect the event when you know that you don't want the code to run. In your case, you are worried that you may still need the event, so why would you disconnect it? archmageofmle 49 — 3y

Answer this question