Skip to content

Commit dd0d867

Browse files
committed
fix: Update teleport utils
1 parent b3a8753 commit dd0d867

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/humanoidteleportutils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"Quenty"
2626
],
2727
"dependencies": {
28+
"@quenty/cframeutils": "file:../cframeutils",
2829
"@quenty/loader": "file:../loader",
2930
"@quenty/raycaster": "file:../raycaster"
3031
},

src/humanoidteleportutils/src/Shared/HumanoidTeleportUtils.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
local require = require(script.Parent.loader).load(script)
77

88
local Raycaster = require("Raycaster")
9+
local getRotationInXZPlane = require("getRotationInXZPlane")
910

1011
local HumanoidTeleportUtils = {}
1112

@@ -66,13 +67,17 @@ end
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
7681
end
7782

7883
--[=[

0 commit comments

Comments
 (0)