Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
harstud 218 Moderation Voter
4 years ago

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

Log in to vote
1
Answered by 4 years ago

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
0
Worked, but it's not WaitFirstChild it is WaitForChild. Thank you for the answer! harstud 218 — 4y
Ad

Answer this question