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

How to effectivly use the CFrame rotation?

Hello, I would like to know how I am able to use the CFrame rotation smoothly. So I am able to rotate an object smoothly.

Here was my experiment but it was a failure:

while wait() do
script.Parent.CFrame = CFrame.new(script.Parent.CFrame) *                                                                       CFrame.Angles(0,0,script.Parent.Rotation.Z + 1)
end

1 answer

✓ Accepted answer

The parameter to CFrame.new(pos) is a position, which is a Vector3, not a CFrame. Use

either

CFrame.new( script.Parent.CFrame.p )

or

CFrame.new( script.Parent.Position )

You probably want to rotate by less than 1. CFrame.Angles parameters, unlike the Rotation property, is measured in radians not degrees. Though it's probably better that you just keep track of the angle rather than read the property as you are doing:

local angle = 0

while wait() do
	angle = angle + 0.1
	script.Parent.CFrame = CFrame.new(script.Parent.Position)
	* CFrame.Angles(0, 0, angle)
end

0.1 radians / .03seconds is 3.33 radians / second or approximately one revolution per second.

1 comment

0

Thanks

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