Teleportation part placing you in the air/surfaces above it

Hello,

So I’ve been encountering this error for quite a while now and decided it’s finally time to do something about it. To start with, it’s a thing where when you step on a part, your avatar will freeze while the screen is fading in to black and out while you’re teleporting to a destination part. The issue here is that if the destination part is inside or has something above it, you’ll spawn on the surface of that rather than the actual surface of the destination part if that makes sense. Before I explain further, here’s a clip real quick of what’s going on:

The parts that are causing this issue:

So yeah, quite a few things that the tp destination part is inside/has above of it. I could easily fix this issue teleporting above surfaces by moving them to the side but the thing is that I can’t move them as I need them to stay there.

Here’s the code inside the teleportation script:

debounce = false

local Dest1 = game.Workspace.Dest1

function onTouched(hit)
	if debounce then return else debounce = true end
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
		if player then
			hit.Parent.Humanoid.WalkSpeed = 0

			local gui = Instance.new("ScreenGui", player.PlayerGui)
			local label = Instance.new("TextLabel", gui)
			label.Size = UDim2.new(2, 0, 2, 0)
			label.Position = UDim2.new(-0.5, 0, -0.5, 0)
			label.BackgroundColor3 = Color3.new(0,0,0)
			label.BackgroundTransparency = 1
			label.Text = ""
			while gui and label and label.BackgroundTransparency > 0 do
				wait()
				label.BackgroundTransparency = label.BackgroundTransparency - 0.01
			end
			if hit then
				hit.Parent:MoveTo(Dest1.Position)
			end
			while gui and label and label.BackgroundTransparency < 1 do
				wait(0.01)
				label.BackgroundTransparency = label.BackgroundTransparency + 0.01
			end
			if gui then
				gui:Remove()
			end
			if hit then
				if hit.Parent:FindFirstChild("Humanoid") then
					hit.Parent.Humanoid.WalkSpeed = 16
				end
			end
		end
	end
	debounce = false
end

script.Parent.Touched:connect(onTouched)

Is there a way to get it to force place you right at the tp destination point? Not so sure how I’d go about this to be honest as there’s little to no resources that I’ve found to help with this.

Have your tried like:

hit.Parent.PrimaryPart.CFrame = Dest1.CFrame?

If the hit’s parent is the character, and the primary part is like the HumanoidRootPart, it should teleport the whole player.

1 Like

hit.Parent:MoveTo(Dest1.Position-Vector3.new(0, 5, 0)) although you may want to change the 5 to adapt it to your script.

Tried doing that right now but didn’t really do much of difference besides breaking the script a little.

1 Like

destination part
cancollide off??

Tried this right now and was changing the 5 to other numbers for a bit and it didn’t really make much of a great difference. Either still giving you the same results shown in the clip or takes you under the floor falling to your death the higher the number is. I tried setting the numbers to negative to see if it could counter it and even then it didn’t make a difference either.

The part already has CanCollide off.

I think you’ll have to end up using SetPrimaryPartCFrame vs MoveTo because MoveTo tries to be ‘smart’ and move you above any parts at the destination. Sometimes this is desirable (to keep things from teleporting inside of other collidable things), and sometimes, as in your case, it is not desireable.

change this line:

	hit.Parent:MoveTo(Dest1.Position)

similar to what he said here:

FYI, this is the same recommendation made in the documentation here:
https://developer.roblox.com/en-us/api-reference/function/Model/MoveTo

Tried it but the transition froze mid black screen.

What I put

hit.Parent.PrimaryPart.CFrame = Dest1.CFrame(1553.054, -115.309, -1789.912)

I’m not getting any errors about this in the Output either which is weird.

You don’t need those numbers. Dest1.Cframe contains all the location information already. Take out the parenthesis part.

Change it to this:
hit.Parent:PivotTo(Dest1.CFrame * CFrame.new(0, 4, 0))

2 Likes