-
What do you want to achieve? I want to have players teleport to a specific place, and a little higher than that place to avoid colliding with the ground
-
What is the issue? You fall down after teleporting to the part’s position
hit.Parent.HumanoidRootPart.CFrame = descendant.Parent.Purchase.CFrame * CFrame.new(0,5,0)
-
What solutions have you tried so far? I’ve looked for solutions online, and have tried the code below (it works), but I’ve had some weird experiences with teleporting players through Position (such as the server and client being way off-sync)
hit.Parent.HumanoidRootPart.Position = descendant.Parent.Purchase.Position + Vector3.new(0,5,0)
local currentHRPCFRotation = hit.Parent.HumanoidRootPart.CFrame.Rotation --get the current CFrame rotation only
local goalPositionCF = CFrame.new(0,5,0)*descendant.Parent.Purchase.CFrame -- get the position
--Cframe.new(0,5,0) to move up in world space rather than relative to the spawn block CFrame, order of operation matters
--combine position and rotation
hit.Parent.HumanoidRootPart.CFrame = currentHRPCFRotation + goalPositionCF.Position
The explanation for why it’s falling over is due to the spawn parts CFrame which is probably rotated specifically this CFrame:
descendant.Parent.Purchase.CFrame
--used within
hit.Parent.HumanoidRootPart.CFrame = descendant.Parent.Purchase.CFrame * CFrame.new(0,5,0)
hence using that CFrame will cause the player to be rotated as well.
And yeah you cannot use .Position to as you noticed. It will generally break the weld of the humanoid root part like below:
2 Likes
you can just use :MoveTo(Vector3)
hit.Parent:MoveTo(descendant.Parent.Purchase.Position)
don’t use it while there’s something above the pad though (or it will teleport you above the “something” I was talking about)