CharacterAdded not firing

hey im pretty sick rn so im gonna make this short, i know theres topics like this but im handling if the character already exists. this works fine with 1 player but anything higher than that it doesn’t do anything past the character line

local function spawnAtPart(part)
	for _, player in Players:GetPlayers() do
		local character = player.Character or player.CharacterAdded:Wait()
		local hrp = character:FindFirstChild("HumanoidRootPart")
		
		if hrp then
			character:PivotTo(part:GetPivot())
			orientCamEvent:FireClient(player, part.CFrame)
			print("Teleported:", player.Name)
		else
			warn("No HumanoidRootPart for", player.Name)
		end
	end
end

output???

ah sorry, when i play singleplayer it prints the teleported line, but multiplayer prints nothing, even a test print i put after the character defining line

trace where you call the function from to find exactly where the code stops. If I had to guess based on what you said the function doesnt even run.

Maybe try local hrp = character:WaitForChild(“HumanoidRootPart”)

1 Like

this is also a good improvement, but considering theres no output if a print is added on line 5, I dont think this is the root issue.

Player.CharacterAdded will never fire if the character already exists. If the Player.Character doesn’t exist at the point of teleporting people, then don’t teleport them. Nil check the character and don’t do anything with them if it is nil. You’re essentially yielding the script indefinitely

1 Like

the problem is that the players aren’t loaded when i call the function, ill work on it later

When do you call the function?

like 0.5 seconds after the server starts :sob: im kind of stupid

Try putting Players.PlayerAdded:Wait().

i did, only worked for singleplayer

edit: nevermind i tried it at a different line and it worked!

1 Like

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