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

How do i script CFrame Straight Rotations?

Asked by 6 years ago

I'm currently scripting CFraming, and I have no idea how to do a full rotation. I understand how to script rotating CFrames, but the point being it is always a bit off. Any help??

1 answer

Log in to vote
0
Answered by 6 years ago

Hi iPhoneDrew,

CFrame rotations become much easier when you start using the .Angles constructor of CFrame and start using math.rad()

Well, I'll just show you a simple example here of how it works.

local part = workspace.Part -- The part you're rotating.

part.CFrame = part.CFrame * CFrame.Angles(0, math.rad(360), 0) -- This will do a full rotation since it just rotates 360 degrees, which is a full circle.

math.rad() takes degrees and returns the degrees in radians. You could also use math.deg() which takes radians and returns it in degrees, but I am more familiar with degrees so I just used math.rad(). Anyways, that's how simple rotation can be.

I hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

0
Thank you sooooo much! IPhoneDrew 9 — 6y
0
No problem. KingLoneCat 2642 — 6y
Ad

Answer this question