Hey, I’m trying to create a teleporting script that makes it when you touch pad1 it teleports you to pad2. Can someone please help me with what I’m doing wrong? The script is located inside of pad1.
local pad1 = script.Parent
local pad2 = workspace.Pads.Pad2
pad1.Touched:Connect(function()
local Humanoid = workspace:FindFirstChild("Humanoid")
if Humanoid then
local HRP = Humanoid.Parent:FindFirstChild("HumanoidRootPart")
if HRP then
HRP.CFrame = CFrame.new(pad2.Position)
else
print("HRP wasnt found")
end
end
end)
Did all of that code, this is what it looks like now
local pad2 = script.Parent
local pad1 = workspace:WaitForChild("Pads"):WaitForChild("pad1")
pad2.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild("Humanoid")
if humanoid then
local humanoid = humanoid.Parent:FindFirstChild("Humanoid")
humanoid.CFrame = CFrame.new(pad1.Position)
else
print("Humanoid wasnt found")
end
end)
script.Parent.Touched:Connect(function(hit)
hit.Parent:FindFirstChild("HumanoidRootPart").CFrame = workspace.part2.CFrame + Vector3.new(0,5,0) --part2 is your secondpart and vector3 plus is made for not get stucked by a second part. You Don't Have To Use PivotTo.
end)