Your problem is that the X, Y, and Z properties of CFrame are readonly. This means that they cannot be set, only accessed as a number. This means that
workspace.Part.CFrame.X = 5
will not work, while
local x = workspace.Part.CFrame.X
print(x)
will work. Again, you cannot change the XYZ properties of CFrame, but you can read them.
We can accomplish what you want, however, by doing the following:
part.CFrame = part.CFrame * CFrame.fromEulerAnglesXYZ(0, math.rad(30), 0)
Here, we are taking the part's CFrame, and setting it to itself. We are then multiplying (although it seems like we are adding, more on that here) it by 0, math.rad(30), 0. Thus the X and Z does not change, only the Y is affected.
On a side note, although CFrame.fromEulerAnglesXYZ works fine, it is more readable and quicker to type to use CFrame.Angles.
Hope I helped.
3 comments
I get a error stating that "fromEulerAnglesXYZ() is not a valid member"
fromEulerAnglesXYZ (alias Angles) is a CFrame constructor, toEulerAnglesXYZ (no alias) is the method to return the angles.
Sorry you're right, adark! I didn't bother to look it up and that was my mistake. Editing answer now.