Why isn't the CharacterAdded working on first join?

Hi, for some reason, this script below I made doesn’t add the particles in player when they join, but after they die/reset it does.

Does it have to wait for the data to load in or something? I’ve tried a lot and nothing worked for me yet.
If you could help I would appreciate it really a lot!

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(character)
		local data = Player:WaitForChild("Data").Wearing
		if data.Value ~= "" then
				local Wearing = Player.Data.Wearing
				local Effect = game.ReplicatedStorage.BuyableParticles:FindFirstChild(Wearing.Value)
				local children = Effect:GetChildren()
				for i = 1, #children do
					if children[i]:IsA("ParticleEmitter") then
						local clone = children[i]:Clone()
						clone.Parent = character:FindFirstChild("HumanoidRootPart")
						clone.LockedToPart = true
					end			
				end
			end
	end)
end)


Have you tried debugging by adding some prints in between your code? If CharacterAdded fires when you reset your character, that means the culprit, based on the information you have provided may be on line 4.

Are you sure that data.Value has been set properly before the character loads for the first time? In this situation, make sure you edit the “Wearing” value before you parent the “Data” to the player. That way, there will be a guarantee that the value won’t be an empty string.

Thanks, helped me a lot :slight_smile:

aaaaaaaaaaaaaaaaaaaaaaaa