CharacterAdded not changing character position?

Hello,

I’m using a CharacterAdded event to change the rootpart position.

What I’m trying to do here is teleport the player to that position instead of the SpawnLocation.

Here is the code bit:

				player.CharacterAdded:Connect(function()
					print("character respawn")
					hrp.CFrame = CFrame.new(10,10,10)
				end)

Yes, I know it’s small :sweat_smile:

The CharacterAddedEvent does fire, but it does not teleport the hrp.

I tried doing a 1 second delay, but it didn’t work either.

If necessary, I can show the whole code.

2 Likes

If this is the full code for CharacterAdded, then you are clearly in error. Since hrp doesn’t exist (because new character - new hrp)

player.CharacterAdded:Connect(function(char)
	print("character respawn")
	wait()
	hrp = char.PrimaryPart
	hrp.CFrame = CFrame.new(10,10,10)
end)

try this

player.CharacterAdded:Connect(function(char)
	repeat task.wait() until char:IsDescendantOf(workspace)
	char.HumanoidRootPart.CFrame = CFrame.new(10,10,10)
end)
1 Like

that wasn’t the full code, I was assuming that bit of code was erroring.

The hrp that I showed had a variable.

I tried the other person’s one and it worked. I’d assume yours would too.

1 Like

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