Teleporter loop

So i made a teleporter where when you touch partA it teleports you to partB, and when you touch partB it teleports you to partA.

But when you touch partA or partB it puts me in a loop constantly teleporting me back and forth.

local Players = game:GetService("Players")

local partA = script.Parent
local partB = game.Workspace.Teleporter2



local function onPartTouch(part)
	local player = Players:GetPlayerFromCharacter(part.Parent)
	
	wait(1)
	
	if player then
			player.Character.PrimaryPart.CFrame = partB.CFrame
	end

end

partA.Touched:Connect(onPartTouch)
1 Like

Its because as soon as you teleport you touch the part

2 Likes

so you need to make an offset for both teleporters

2 Likes

how exactly do i do that, im quite new to programming

You need to use CFrame.New() and Add it with the teleportpart

1 Like