My teleports work fine, but after some gear is equipped, it refuses to teleport a player and it literary renders the teleporter unusable.
Here’s the error:
Script:
--By zamsongod.
--Unlike Clockwork's teleporter, this one teleports ANYTHING not just people!
--Make sure the Part to teleport to is in the same group as this Part.
--Feel FREE to Copy, Abuse and Covet!
local Teleport = "TP3" --Put the name of the Part between the ""s.
function Touch(hit) --Indicates that the Part has been Touched.
if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce.
local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to.
hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end --Takes you there and Ends the Function.
script.Parent.Touched:connect(Touch) --Listens out for Touchers.
As @ElliottLMz mention earlier, you need to use :MoveTo() which looks like this.
--By zamsongod.
--Unlike Clockwork's teleporter, this one teleports ANYTHING not just people!
--Make sure the Part to teleport to is in the same group as this Part.
--Feel FREE to Copy, Abuse and Covet!
local Teleport = "TP3" --Put the name of the Part between the ""s.
function Touch(hit) --Indicates that the Part has been Touched.
if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce.
local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to.
hit.Parent:MoveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end --Takes you there and Ends the Function.
script.Parent.Touched:connect(Touch) --Listens out for Touchers.
You can easily use CFrame in this situation. Here is an example on how to use it in the script you are using:
local Teleport = "TP3"
function Touch(hit)
if script.Parent.Locked == false and script.Parent.Parent:FindFirstChild(Teleport).Locked == false then
script.Parent.Locked = true
script.Parent.Parent:FindFirstChild(Teleport).Locked = true
local Pos = script.Parent.Parent:FindFirstChild(Teleport)
hit.Parent.CFrame = CFrame.new(Vector3.new(Pos.Position))
wait(1)
script.Parent.Locked = false
script.Parent.Parent:FindFirstChild(Teleport).Locked = false
end
end
script.Parent.Touched:Connect(Touch)
Vector3.new(Pos.Position) Position is already a Vector3 value. You do not need to turn it into one.
Moreover, using CFrame here can create a lot of overhead technically. MoveTo(Vector3) internally does this, however it does it on the C end in a fashion that helps reduce lag and performance issues.
local tp3 = path_to_tp3
local can_tp = true
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not can_tp then return end
can_tp = false
hit.Parent:MoveTo(tp3.Position)
wait(1)
can_tp = true
end
end)