I am trying to make a teleport pad and keep getting this error. How can I fix?
local Pad2 = game.Workspace.TeleportPad2
script.Parent.Touched:Connect(function(touchPart)
if touchPart and touchPart.Parent and touchPart.Parent.Humanoid and
touchPart.Parent.currentlyTeleporting.Value == false then
local Character = touchPart.Parent
local teleportLocation = CFrame.new(Pad2.CFrame.X, Pad2.CFrame.Y + 5, Pad2.CFrame.Z)
Character:SetPrimaryPartCFrame(teleportLocation)
local teleportingValue = Character.currentlyTeleporting teleportingValue.Value = true wait(3) teleportingValue.Value = false end
end)
I think I might know what the problem is here. The script might be better to look more like this:
local Pad2 = game.Workspace.TeleportPad2 script.Parent.Touched:Connect(function(touchPart) local Humanoid = touchPart.Parent:FindFirstChild("Humanoid") if touchPart and touchPart.Parent and Humanoid and touchPart.Parent.currentlyTeleporting.Value == false then local Character = touchPart.Parent local teleportLocation = CFrame.new(Pad2.CFrame.X, Pad2.CFrame.Y + 5, Pad2.CFrame.Z) Character:SetPrimaryPartCFrame(teleportLocation) local teleportingValue = Character.currentlyTeleporting teleportingValue.Value = true wait(3) teleportingValue.Value = false end end)
What has been changed?
and touchPart.Parent.Humanoid
in line 5 with Humanoid
. to check if the humanoid from the line I added at line 4 local Humanoid = touchPart.Parent:FindFirstChild("Humanoid")
simply trying to get it, returning nil if nothing is there exists.What is this doing?