Struggling with teleporting a model out of another part to a different location

I found out that parts don’t fire .Touched when they touch an anchored part. I tested it in my own studio

1 Like

I know a fix you can do.
Move kart.Anchored to after you use PivotTo

Anchored parts dont fire .Touched? Wonder who at roblox decided that was a good idea, half the time touching parts are usually anchored.

The kart flung backwards, but other than that nothing changed.

This is because since parts don’t register collisions with other anchored parts, you can move the kart then anchor it, if this doesn’t work, add a task.wait() between it

Do this then send a video of it

also so this is what that part of the script should be

local function col(box)
	local boxParent = box.Parent
	local outOfBounds = boxParent:FindFirstChild("COL_BOUNDARY")

	if outOfBounds then
		if isFloating == false then
			kart.HitSound.Playing = true
			isFloating = true

			driverPlayer.PlayerGui.RaceHUD.ScreenFade.OOBAnimation:FireClient(driverPlayer) --This line isn't really important, it just fires the UI animation for driving out of bounds.
			kart.Parent.PrimaryPart = kart
			wait(0.5)
			kart.Parent:PivotTo(respawnCFrame)
			task.wait(1) -- try 0.5 if this is too long
			kart.Anchored = true

			kart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
			kart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)

			isFloating = false
			wait(1)
			kart.Anchored = false
			kart.Parent.PrimaryPart = nil
		end
	end
end

kart.Touched:Connect(col)

Same exact result as the video I sent, I assume what I’d need to do is somehow move the kart out of the OOB box smoothly and THEN use :PivotTo(), I’m just not sure of how I’d do that.

also probably change

task.wait()

into

task.wait(1)

because task.wait() without a number is 0.015 seconds

sorry the delay wasn’t long enough

also is 1 is too long you can try 0.5

The delay doesn’t seem to do anything

did you copy and paste the exact function i sent?

try this one instead then

local function col(box)
	local boxParent = box.Parent
	local outOfBounds = boxParent:FindFirstChild("COL_BOUNDARY")

	if outOfBounds then
		if isFloating == false then
			kart.HitSound.Playing = true
			isFloating = true

			driverPlayer.PlayerGui.RaceHUD.ScreenFade.OOBAnimation:FireClient(driverPlayer) --This line isn't really important, it just fires the UI animation for driving out of bounds.
			kart.Parent.PrimaryPart = kart
			wait(0.5)
			kart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
			kart.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
			kart.Parent:PivotTo(respawnCFrame)
			task.wait(0.25) 
			kart.Anchored = true

			isFloating = false
			wait(1)
			kart.Anchored = false
			kart.Parent.PrimaryPart = nil
		end
	end
end

kart.Touched:Connect(col)

Same result except the kart doesn’t stay in place when it touches the OOB region. So unless you drive the kart out of the box before the teleport happens, the same issue occurs.

Im not sure if this helps at all, but I just recreated this teleport checkpoint thing using my character

local RespawnPosition

local checkpoints = {
	game.Workspace.Checkpoint1,
	game.Workspace.Checkpoint2,
}

local OOBparts = {
	game.Workspace.OOBpart,
}

function OOBfunc(part)
	local character = part.Parent
	if character:IsA("Model") and character:FindFirstChild("Humanoid") and RespawnPosition then
		character:SetPrimaryPartCFrame(CFrame.new(RespawnPosition))
	end
end

for _, oobPart in ipairs(OOBparts) do
	oobPart.Touched:Connect(OOBfunc)
end

local function SetRespawnPosition(checkpoint)
	RespawnPosition = checkpoint.Position
end

for _, checkpoint in ipairs(checkpoints) do
	checkpoint.Touched:Connect(function() SetRespawnPosition(checkpoint) end)
end

And yes I know I didn’t use PivotTo, ill have to get used to that another time

Did you try walking into the same OOB part twice???

You can find a way to counter this by not having the OOB part anchored, and using something else to keep it in place. Maybe bodyposition, velocity, or align position.

My Parts are anchored and cancollide is false, if we set them both to false it will fall through the ground without anything else keeping it in place

The script wouldn’t work with multiple karts so you would need to check if the part is the same by using

if part == kart and RespawnPosition then
	kart.Parent:SetPivot(CFrame.new(RespawnPosition))
end

instead of

local character = part.Parent
	if character:IsA("Model") and character:FindFirstChild("Humanoid") and RespawnPosition then
		character:SetPrimaryPartCFrame(CFrame.new(RespawnPosition))
	end