Players joining before Scripts yield?

Is it possible, in a live game, for game.Players.PlayerAdded to fire before all enabled Script objects have had a chance to run and yield?

This usually happens in studio’s Play Solo. I usually include a loop that takes place a second or two after my PlayerAdded loop in edge cases like this.

local TaggedPlayers = {}

     TaggedPlayers[Player] = true
     --do your stuff


for i, v in pairs(game.Players:GetPlayers()) do
     if not TaggedPlayers[v] then
          --do the same stuff

Thanks, I’'m aware of this,but not sure if this applies to a live game as well.

1 Like

I’ve only seen it occur in a live game once. It doesn’t happen often, but it’s possible if the player has godspeed internet.

1 Like

It happens quite often for me since my game has to load some modules first, and once those are loaded the Player added event gets hooked. When I saw that it’s not getting fired when I join, I had to make a for loop on each player and then manually call the added function myself. And I don’t even really have godspeed internet. So it depends on the situation. Either it’s the server still running all scripts or the players internet is too fast for the scripts.

The fix to this problem is to loop through the players once everything is done loading.

local function initializePlayer(plr)
--Code here
for i,v in pairs(game.Players:GetChildren()) do
1 Like