File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
src/humanoidteleportutils Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 2525 " Quenty"
2626 ],
2727 "dependencies" : {
28+ "@quenty/cframeutils" : " file:../cframeutils" ,
2829 "@quenty/loader" : " file:../loader" ,
2930 "@quenty/raycaster" : " file:../raycaster"
3031 },
Original file line number Diff line number Diff line change 66local require = require (script .Parent .loader ).load (script )
77
88local Raycaster = require (" Raycaster" )
9+ local getRotationInXZPlane = require (" getRotationInXZPlane" )
910
1011local HumanoidTeleportUtils = {}
1112
6667 @param rootPart BasePart
6768 @param position Vector3
6869]=]
69- function HumanoidTeleportUtils .teleportRootPart (humanoid , rootPart , position )
70+ function HumanoidTeleportUtils .teleportRootPart (humanoid , rootPart , position : Vector3 | CFrame )
7071 assert (typeof (humanoid ) == " Instance" and humanoid :IsA (" Humanoid" ), " Bad humanoid" )
7172 assert (typeof (rootPart ) == " Instance" and rootPart :IsA (" BasePart" ), " Bad rootPart" )
72- assert (typeof (position ) == " Vector3" , " Bad position" )
73+ assert (typeof (position ) == " Vector3" or typeof ( position ) == " CFrame " , " Bad position" )
7374
7475 local offset = HumanoidTeleportUtils .getRootPartOffset (humanoid , rootPart )
75- rootPart .CFrame = rootPart .CFrame - rootPart .Position + position + offset
76+ if typeof (position ) == " Vector3" then
77+ rootPart .CFrame = rootPart .CFrame - rootPart .Position + position + offset
78+ else
79+ rootPart .CFrame = getRotationInXZPlane (position ) + offset
80+ end
7681end
7782
7883--[=[
You can’t perform that action at this time.
0 commit comments