CFrame.Angles Not working properly

So on the right I have a part that’s imitating the left part’s orientation with CFrame. The problem is, it doesn’t do it properly, and it’s causing all sorts of issues with my building script.

while wait() do
	script.Parent.CFrame=CFrame.new(script.Parent.Position)*CFrame.fromEulerAnglesXYZ(math.rad(workspace.shah.Orientation.X),math.rad(workspace.shah.Orientation.Y),math.rad(workspace.shah.Orientation.Z))
end

This is all my script is. Yes I have used math.rad(). I don’t know why it don’t work.

2 Likes

Quick question, couldn’t you use AlignOrientation | Roblox Creator Documentation for what you’re doing?

No. As I said, it requires precise and instant calculations, because it’s for my building system. No hacky solutions, unfortunately.

1 Like

You can change the responsiveness of the align orientation pretty high

Still no can do. I can’t rely on physics for these types of things.

Can’t you just do:

local p1 = script.Parent
local p2 = game.Workspace:FindFirstChild("shah")
local offset = 5

p1.CFrame = p2.CFrame * CFrame.new(offset, 0, 0)

Did you mean to use CFrame.fromEulerAnglesXYZ()? Because your post title is mentioning CFrame.Angles

Can we get an actual CFrame expert here please. If you spent time to read like the three sentences that I wrote in the original post, you’d know I’m trying to work with converting orientation to CFrame.

To @xZylter, CFrame.Angles is the same as CFrame.fromEulerAnglesXYZ(). It says so on the wiki, and tests prove they’re the same. I just made it shorter to attract more people to the post.

1 Like

I’ll get back to you on this, but it might be with how Roblox handles orientation, it’s very wacky. The issue’s cause to me seems less as CFrame doing the wrong thing. but instead Roblox’s tools doing weird manipulations to get the results you want.

Atleast on the X axis, I saw studio apply 180 degree rotations on the Z and Y axises when all I was doing was applying rotation to X Axis.

Use ToOrientation and fromOrientation:

This is bound to renderstep which is why it’s instant, but it will work from the server as well but it’ll be a little delayed. If you’re doing this I suggest a custom wait function as wait() is not great for this because it’s not always accurate

6 Likes