"Attempted to index nil with 'HumanoidRootPart'"

Hello,

I’m trying to teleport the player from 1 pad to another. Everything works fine but I don’t know what this error means and I don’t know what is wrong with my script.

Output:

Script:

Thanks,
Skylexion

try this?

for _, player in pairs(game.Players:GetPlayers()) do
   local character = player.Character or player.CharacterAdded:Wait()
   character.HumanoidRootPart.CFrame = GameSpawn.CFrame
end

Character could be nil either due to the player dying or other factors,

Basically do what @HugeCoolboy2007 mentioned since it waits for the character to exist before doing anything

Still not working. No output but the player still bounces.

What do you mean by “still bounces?”

Like the players character sinks into the baseplate and comes back up

When setting the CFrame, at the end add

* CFrame.new(0,3.25,0)

Example

Character.HumanoidRootPart.CFrame = GameSpawn.CFrame * CFrame.new(0,3.25,0)

I rewrote the script the exact way and it worked. Maybe something wrong with studio idk.

Hmm, maybe so, least it’s working though. You should set one of the posts as the solution so if anyone has the same problem they can easily find the solution here.

If you’re saying that it didn’t display that error again, it could be that none of the characters were not loaded by the time that event was ran

1 Like