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

While true do rotation scripts aren't working. Why?

while true do
	script.Parent.Rotation = script.Parent.Rotation + Vector3.new(0,15,0)
	wait(.1)
end

I have my script, and it works for 2 seconds until it stops and rapidly moved side to side. I've tried doing it as a for loop, but that doesn't work either. Why is it not working?

1 answer

✓ Accepted answer

It has to do with vectors constraining to the world axis so that once it reaches the "limit" it's actually going -15 on the y axis, making it teeter back and forth.

The answer is to use CFrame instead: script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0,15,0)

4 comments

0

CFrame.Angles uses radians while Rotation uses degrees. 15 radians is more than two full revolutions (859 degrees).

0

Thanks! I didn't know you could CFrame rotation like that!

0

Also, why does having a 1 seem to go WAY faster than having a 15 there?

0

Like BlueTAlesm said, it's in radians. 1 radian is 180 degrees so if you want it to rotate 15 degrees you multiply it by pi and divide it by 180. Or you can use the function located in the math table: rad. * CFrame.Angles(0, math.rad(15), 0)

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