Hey devs, I’m a builder on roblox who knows nothing about scripting, but my partners a scripter who doesn’t have access to the forum, so here is my issue. He is making a teleporting system using two parts. When the player touches the part they teleport to the other part, the system works and functions the problem is that its a two way teleporter. So when the player touches one of the teleporter part to go to the other part, the moment the player arrives at the other part, he instantly teleport back. Leaving it so that the player does not have a chance to get off the teleportation part, making the player stuck in a infinite loop of traveling back and forth between parts. If anyone has a answer on how to fix this please respond. Thanks!
There should be an interval that the pads must wait for before teleporting something/someone.
For example:
function CheckPlayerTouching(Character)
for _,part in pairs(Character:GetChildren()) do
for _p in pairs(part:GetTouchingParts()) do
if p == script.Parent then
return true
else
return false
end
end
end
end
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
wait(2)
if CheckPlayerTouching(hit.Parent) then
hit.Parent.HumanoidRootPart.CFrame = workspace.TeleportPad2.CFrame
end
end
end)
So for this my scripter should just check to see if the player is touching the part 2 seconds after telporting, then if the player is teleport the player again?
You can change the interval to whatever you like, but the point is, it ensures that you don’t get caught into an infinite loop. Personally, I’d increase the interval from 2 seconds, but it should vary based on you and your scripter’s goal.