My teleportation script works fine but I’m getting an error in output every time. What does Workspace.Teleports.Crane2Upper.Script:4: attempt to index nil with ‘CFrame’ mean?
I know my script works fine but how do I remove this error?
local TP = game.Workspace.Teleports.Crane2Lower
script.Parent.Touched:Connect(function(part)
local hum = part.Parent:FindFirstChild("HumanoidRootPart")
hum.CFrame = TP.CFrame + Vector3.new(0,5,0)
end)
Are you sure your block isnt touching another object in the workspace that is triggering the touched function such as the baseplate. To get around this just check if your hum variables actually exits by doing:
script.Parent.Touched:Connect(function(part)
local hum = part.Parent:FindFirstChild("HumanoidRootPart")
if hum then
hum.CFrame = TP.CFrame + Vector3.new(0,5,0)
end
end)
local part = script.Parent
local TPS = workspace:WaitForChild("Teleports")
local TP = TPS:WaitForChild("Crane2Lower")
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
local hum = hit.Parent:FindFirstChild("HumanoidRootPart")
hum.CFrame = TP.CFrame + Vector3.new(0,5,0)
end
end)