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:
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.
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.
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.