Hello, Im having a problem using teleporters, this are free models and have this script:
-- local Teleport = "ToMoon"
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:moveTo(Pos.Position) wait(1)script.Parent.Locked = false script.Parent.Parent:FindFirstChild(Teleport).Locked = false
end
end
script.Parent.Touched:connect(Touch)
Parts are called “To Earth” and “To Moon”
Sometimes and not always, this error apears in console when touching the teleport pad, and of course, I dont get teleported
I searched the error and Im not the only one with this problem, but, I couldnt fix it with those previous posts.
-- local Teleport = "ToMoon"
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.Humanoid:MoveTo(Pos.Position)
wait(1)
script.Parent.Locked = false
script.Parent.Parent:FindFirstChild(Teleport).Locked = false
end
end
script.Parent.Touched:Connect(Touch)
I dont really understand programming sorry, this are literally free teleports, I just see all the teleports in free models have this error, may you be more specific or clear?
-- local Teleport = "ToMoon"
local SP = script.Parent
function Touch(Hit)
if SP.Locked == false and SP.Parent:FindFirstChild(Teleport).Locked == false then
SP.Locked = true
SP.Parent:FindFirstChild(Teleport).Locked = true
local Pos = SP.Parent:FindFirstChild(Teleport)
local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
if Humanoid then
Humanoid:MoveTo(Pos.Position, Pos)
end
wait(1)
SP.Locked = false
SP.Parent:FindFirstChild(Teleport).Locked = false
end
end
SP.Touched:Connect(Touch)
So, the accessory instance is not a part that can be seen in the game, and if its an accessory thats wearable, you can just get the BasePart inside it which has a move to function.
I saw that all teleports in Toolbox have the same problem, do you guys know any simple teleport pad that know works fine?
Also, do you guys understand why sometimes it works and sometimes it doesnt? it is just random
local Teleport1 = nil -- change this to the path of one of your tp pads
local Teleport2 = nil -- change this to the path of the other tp pad
local DelayTime = 1 -- change this to whatever you want
local Debounce = {}
Teleport1.Touched:Connect(function(Hit)
local Character = Hit.Parent
if Character then
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
if Debounce[Character.Name] then
local TimeNow = tick()
if (TimeNow - Debounce[Character.Name].LastTeleported) >= DelayTime then
Debounce[Character.Name] = nil
else
return
end
end
Debounce[Character.Name] = {
LastTeleported = tick()
}
Character:SetPrimaryPartCFrame(Teleport2.CFrame)
end
end
end)
Teleport2.Touched:Connect(function(Hit)
local Character = Hit.Parent
if Character then
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
if Debounce[Character.Name] then
local TimeNow = tick()
if (TimeNow - Debounce[Character.Name].LastTeleported) >= DelayTime then
Debounce[Character.Name] = nil
else
return
end
end
Debounce[Character.Name] = {
LastTeleported = tick()
}
Character:SetPrimaryPartCFrame(Teleport1.CFrame)
end
end
end)
local Teleport1 = workspace:WaitForChild("Office TP"):WaitForChild("ToEarth")
local Teleport2 = workspace:WaitForChild("Office TP"):WaitForChild("ToMoon")
local DelayTime = 1 -- change this to whatever you want
local Debounce = {}
Teleport1.Touched:Connect(function(Hit)
local Character = Hit.Parent
if Character then
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
if Debounce[Character.Name] then
local TimeNow = tick()
if (TimeNow - Debounce[Character.Name].LastTeleported) >= DelayTime then
Debounce[Character.Name] = nil
else
return
end
end
Debounce[Character.Name] = {
LastTeleported = tick()
}
Character:SetPrimaryPartCFrame(Teleport2.CFrame)
end
end
end)
Teleport2.Touched:Connect(function(Hit)
local Character = Hit.Parent
if Character then
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
if Debounce[Character.Name] then
local TimeNow = tick()
if (TimeNow - Debounce[Character.Name].LastTeleported) >= DelayTime then
Debounce[Character.Name] = nil
else
return
end
end
Debounce[Character.Name] = {
LastTeleported = tick()
}
Character:SetPrimaryPartCFrame(Teleport1.CFrame)
end
end
end)
And by the way, you only have to use 1 script for that to work. Remove the scripts inside your tp parts and insert a script inside the TP Office model and paste the code there.