So I basically want to get the rotation that the character is facing relative to the world space, for example if he is facing one side that would be known as angle and the opposite facing side would be -angle. For example, if my player’s character is facing North, then the negative angle would be South and I want that angle in degrees if you get what I mean. I know you can use lookVector but I really need the angle that the character is facing in the world.
task.wait(3)
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local function getRotationAngle()
local root = character:WaitForChild("HumanoidRootPart")
local lookVector = root.CFrame.lookVector
local angle = math.deg(math.atan2(lookVector.x, -lookVector.z))
return angle
end
local rotationAngle = getRotationAngle()
print(rotationAngle)
HRP.Position:Angle(Vector3.new(0, 0, 0)) because you’re trying to get the angle relative to the world space which would be position 0,0,0 right? Idk try it out
Wouldn’t it just be HumanoidRootPart.Orientation.Y?
Since humanoid root part is a Base part, it has an orientation value, in angles, for all 3 axes
All you need would hypothetically be
Local plr = --path to player
Local char = plr.Character or plr.CharacterAdded:wait()
Local HRP = char:WaitForChild("HumanoidRootPart")
Local RotationY = HRP.Orientation.Y
Correct me if I’m wrong
Sent from phone so bad capitalization
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local directionToCenter = (Vector3.new(0, 0, 0) - character:GetPivot().Position).Unit
local directionAngle = math.deg(character:GetPivot().LookVector:Angle(directionToCenter))
print(directionAngle)
In the code above, the center is position 0, 0, 0 in the game. Playtest and copy paste it into the console and spin your character around.
If the player is facing 0,0,0 the angle should be smaller than if the player is looking away from the center
I don’t think it’s working for me, because it is showing different numbers for opposite movement, but I might be wrong and it works and I just can’t detect that it does. Thanks so much for your help!