Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Teleportation script causing error, need a fix, can anyone help me out?

I am making a Roblox animation inside of Roblox, and my teleport script is just broken. Can someone help me? It's a local script. The error is this: 22:55:38.810 - Players.Ha_rriz.PlayerGui.ScreenGui.LocalScript:7: attempt to index local 'HumanoidRoot' (a nil value)

local Players = game:GetService('Players')
local Player = Players.LocalPlayer
local Character = Player.Character
local PartTele = game.Workspace:FindFirstChild("TeleportPart1").CFrame
local HumanoidRoot = Character:FindFirstChild("HumanoidRootPart")
HumanoidRoot.CFrame = PartTele

1 answer

✓ Accepted answer

Try this.

local Players = game:GetService('Players')
local Player = Players.LocalPlayer
local Character = Player.Character
local PartTele = game.Workspace:FindFirstChild("TeleportPart1").CFrame
local HumanoidRoot = Character:WaitFirstChild("HumanoidRootPart")
HumanoidRoot.CFrame = PartTele

1 comment

0

Worked, but it's not WaitFirstChild it is WaitForChild. Thank you for the answer!

This discussion is preserved as it was. New answers, comments, and votes are closed.