Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When I rotate an object in Studio using a script, it does not rotate correctly...?

I have always had this problem and am finally looking into it. I have a code that rotates a brick 90*. Yet for some reason it is not rotating correctly. I have heard stuff such as floating point errors and stuff but I don't think that is the problem. Please help!

local part = script.Parent

part.CFrame = part.CFrame * CFrame.Angles(math.deg(0),math.deg(90),math.deg(0))

1 answer

✓ Accepted answer

You're looking for math.rad(x) which takes degrees and converts to radians as opposed to math.deg(x) which takes radians and converts to degrees. The CFrame.Angles function takes the angles as radians so you need to adjust your arguments.

To reiterate, you want:

local part = script.Parent

part.CFrame = part.CFrame * CFrame.Angles(math.rad(0),math.rad(90),math.rad(0))

Hopefully that answers your question for you

2 comments

0

Btw, you don't have to do math.rad(0) since it's 0 anyways, but other than that, you're right :3

0

Thanks dude that really helped

This discussion is preserved as it was. New answers, comments, and votes are closed.