How could I SET a player's rotation, not just change it?

Hello. So I’ve been looking around for some help on rotating the player, and it’s worked good. However, there is an issue. I want the player’s character to be SET to 90 degrees on the y axis, not just changed by it.

Script so far:

local char = player.Character
local humrp = char:FindFirstChild("HumanoidRootPart")
humrp.CFrame = CFrame.new(2.794, 53.656, 0.552) * CFrame.fromEulerAnglesXYZ(0, 90, 0)

(player is already defined earlier)

For example, if a player’s rotation is (0, -90, 0) and I use the code, it will set the new rotation to (0, 0, 0) but I want it to be (0, 90, 0).

1 Like

That’s because CFrame.fromEulerAnglesXYZ accepts values in radians, not degrees.

Replace humrp.CFrame = CFrame.new(2.794, 53.656, 0.552) * CFrame.fromEulerAnglesXYZ(0, 90, 0)
with:

humrp.CFrame = CFrame.new(2.794, 53.656, 0.552) * CFrame.fromEulerAnglesXYZ(0, math.pi/2 or math.rad(90), 0)
2 Likes

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