PlayerAdded not firing?

  1. What do you want to achieve? Clone a folder when player joins.

  2. What is the issue? PlayerAdded sometimes does not even fire.

  3. What solutions have you tried so far? Tried doing a taskwait doesnt work. Also locating stats somewhere too.

Players.PlayerAdded:Connect(function(Player)
	local __STATS = script:FindFirstChild("Stats"):Clone()
	__STATS.Name = Player.Name 
	__STATS.Parent = ReplicatedStorage
	Player.CharacterAdded:Connect(function(Character)
             -- rest of the script..
	end)
end)

This happens on cases where the player loads faster than the server, especially in Studio testing. Try forcing the function on any existing players there could be, after hooking the function, by looping through any possible players once and execute all that.

I’ll just make a backup bindable event

__BACKUPEVENT:Fire(Player.Name)
--
__BCKUPEVENT.Event:Connect(function(__NAME)
	if ReplicatedStorage:WaitForChild(__NAME) then
		error(__NAME.. " ALREADY EXISTS!!")
	elseif not ReplicatedStorage:WaitForChild(__NAME) then
		CREATESTATS(__NAME)
	end
end)

This post could help.

1 Like

For reference:

1 Like

Reason: studio loads both the character and scripts which means, the player is added before it can connect the function.

So that means the script will load just fine in-game?

Yup. Unless there are errors in the script of course.

1 Like