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

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

Asked by 9 years ago
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

Log in to vote
1
Answered by 9 years ago

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)

0
CFrame.Angles uses radians while Rotation uses degrees. 15 radians is more than two full revolutions (859 degrees). BlueTaslem 18071 — 9y
0
Thanks! I didn't know you could CFrame rotation like that! Lightdrago 95 — 9y
0
Also, why does having a 1 seem to go WAY faster than having a 15 there? Lightdrago 95 — 9y
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) jakedies 315 — 9y
Ad

Answer this question