PivotTo() spawns player in air?

I’m attempting to teleport a target directly in front of the player using :PivotTo(), but they spawn somewhat in the air. How can I fix this?

target:PivotTo(CFrame.lookAt(callerHumanoidRootPart.CFrame * Vector3.new(0,0,-5), callerHumanoidRootPart.Position))

This is running on the server.

Try changing

callerHumanoidRootPart.CFrame * Vector3.new(0,0,-5)

to

(callerHumanoidRootPart.CFrame * CFrame.new(0,0,-5)).Position

doesn’t seem to be working either

Could you show me how it looks like?

https://gyazo.com/7b30300858c197f5a552df5421627b39

You could do something like this – although :GetModelCFrame() is considered deprecated, it still works.

local A = workspace.A
local B = workspace.B

local CF = workspace.B:GetModelCFrame()*CFrame.new(0,-B:GetExtentsSize().Y/2,0)

workspace.A:PivotTo(CF * CFrame.new(0,0,-5)*CFrame.Angles(0,math.rad(180),0))

Result:

workspace.B:PivotTo(workspace.A:GetPivot() * CFrame.new(0, 0, -5) * CFrame.fromOrientation(0, math.pi, 0))

Aah – I didn’t realize GetPivot() was a method, much better!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.