Why does Rotation.X,Y,Z always Return 0?

I was making a plugin that would convert R6 Rigs Joints.C0 into code and when I tested it the Rotation was not Actually Returning the C0 Rotation instead It would return 0

the Code Looks Like this

LS.C0.Rotation.X..", "..LS.C0.Rotation.Y..", "..LS.C0.Rotation.Z

And it would always Result in 0. And i have tried X,Y,Z Vector but It didn’t Work either

Try just returning LS.C0.Rotation (without .X) and see if the whole rotation attribute is 0, or is the problem with other parts of the script

I tried it on the baseplate and it gave me
0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1

If you’re experiencing issues with the rotation values of the joints, there are a few Solotions i can think of :)))

  1. Ensure the joint you’re accessing has a non-zero rotation value: Double-check that the joint you’re interested in actually has a rotation applied to it. If the joint’s rotation is not set or is set to zero, you’ll naturally get a result of zero when accessing the rotation values.
  2. Verify that you’re accessing the correct property: Make sure you’re accessing the correct property for obtaining the rotation values. In Roblox, the rotation of a JointInstance is stored in the CFrame property, not directly in the Rotation property. You need to access the rotation values from the CFrame using CFrame:ToEulerAnglesXYZ() or CFrame:ToOrientation().
  3. Use the appropriate method to extract rotation values: Instead of accessing the Rotation property directly, you can use the ToEulerAnglesXYZ() method to extract the rotation values in the desired format (X, Y, Z angles). Here’s an exaple of how you could modify your code to use this method:

local rotation = LS.C0:ToEulerAnglesXYZ()
local rotationString = rotation.X … ", " … rotation.Y … ", " … rotation.Z

replace LS.C0 with the actual joINt YoU WaNt. :))

I Tried this and at the Part where it Converts I got an error attempt to index number with ‘X’

LS.C0 is a Cframe. CFrame.Rotation returns a copy of the cframe except the position is set to 0, 0, 0, thus indexing Rotation.X would return 0, and the same for .Y and .Z.

To actually get its rotation values, you can use :ToEulerAnglesXYZ() or :ToEulerAnglesYXZ(). Both of them returns 3 numbers. The former returns the values of the angles as if the rotations were applied in X->Y->Z order, while the latter is if the angles were applied in Y->X->Z order, similar to the Orientation property you see in the properties tab.

local rotX, rotY, rotZ = LS.C0:ToEulerAnglesYXZ()
3 Likes

I’ll Try this now and See if it works

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