Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
2
Answered by
EgoMoose 802 Moderation Voter
6 years ago
Edited 6 years ago

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

0
Btw, you don't have to do math.rad(0) since it's 0 anyways, but other than that, you're right :3 Amiaa16 3227 — 6y
0
Thanks dude that really helped TheFierceWaffle 64 — 6y
Ad

Answer this question