PlayerAdded Event not firing

Hello, I’m experiencing a problem that i cant seem to fix,

However I noticed that the player added event only works if i played in 2 clients
image

My conclusion is that the player gets added before the scripts even executes thus missing the player getting added.

Your conclusion is correct. This is however not an issue when actually running the game, as the server starts completely before the client joins (as demonstrated when running 2 clients).

One way to do it is something along these lines:

local Players = game:GetService("Players")

function playerJoined(player: Player)
	...
end

for _, player in pairs(Players:GetPlayers()) do -- Make sure all already connected players are run
	playerJoined(player)
end

Players.PlayerAdded:Connect(playerJoined) -- Make sure all subsequent players are run
3 Likes

Thanks i’m a bit dumb sometimes lol

1 Like

image

remove this. you’re using WaitForChild which does the same thing

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.