Rotation prints 0

I have tried several methods of printing the rotation of a part or model, none of them have worked

now heres an example:

local x, y, z = workspace.Car.WorldPivot.Rotation:ToOrientation()
print(math.deg(x), math.deg(y), math.deg(z))

it just returns 0

and here too:

local x = workspace.musicPart.CFrame.XVector.X
local z = workspace.musicPart.CFrame.XVector.Z
print(x,z)

they print some long numbers but its always 1 or 0 idk
and here:

local x = workspace.musicPart.CFrame.X
local z = workspace.musicPart.CFrame.Z
print(x,z)

and here i get 0 too:

local x = workspace.musicPart.Rotation.X
local z = workspace.musicPart.Rotation.Z
print(x,z)

same as here:

local x = workspace.musicPart.Orientation.X
local z = workspace.musicPart.Orientation.Z
print(x,z)

they all don’t print the rotation, ive been struggling for around 2 hours and i can’t figure it out, but they do work if i rotate them before test playing, but if i rotate them in the game nothing happens. please i need help!

2 Likes

When you test, by default you are a Client, so changing the rotation of something will not be visible to a server script. Could that be it?

1 Like

no, i dont know but im trying to make like a system if the car is flipped that it rotates but ignore that, im focusing on how i could print the rotation of the car, but they print 0

1 Like

Do you actually need 3 rotation angles or just whether the top of the car is facing up?

1 Like

I need the rotation angles so i can flip the car if the angle is above 45 or under -45
if theres a different method than rotation so the car gets back up with bodygyro tell me

you could always do this to check if the car is upside down:

local orientation_angle = math.acos(workspace.Car.WorldPivot.UpVector:Dot(Vector3.yAxis))

if (orientation_angle > math.pi/4) then
    --flip car
end

it doesnt do anything, not even printing

print orientation angle outside of the if statement. Make sure that the part your checking has the upvector actually facing up

i did and its still printing 0

Actually the issue might be world pivot. I’m not sure if it actually takes rotations of the parts within the model into account. If you have a primary part inside the model, it may be better to use GetPrimaryPartCFrame instead for reading the models cframe

this kind of works:

workspace.Car:GetPrimaryPartCFrame(Vector3.xAxis)

but it gives me these numbers:
-16.3778706, 3.92321491, 167.306717, 0.999997079, 0.0016545197, 0.00172889291, -0.00165881298, 0.99999553, 0.0024848457, -0.00172479253, -0.00248770649, 0.99999541

the numbers -16.3778706, 3.92321491, 167.306717 is the position of the part it printed that out but how do i print the rotation?

(I don’t know if im using it right)

do this

local orientation_angle = math.acos(workspace.Car:GetPrimaryPartCFrame().UpVector:Dot(Vector3.yAxis))

if (orientation_angle > math.pi/4) then
    --flip car
end
1 Like

The WorldPivot property will be relative to the PVInstance, not to the world. What you’re looking for is model:GetPivot():ToOrientation()

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