First of all, the block I'm rotating has a mesh in it. But the following code breaks when it gets to the rotation 90 on the Y axis
local b = script.Parent
while true do
wait(.01)
b.Rotation = b.Rotation + Vector3.new(0, 1, 0)
end
First of all, the block I'm rotating has a mesh in it. But the following code breaks when it gets to the rotation 90 on the Y axis
local b = script.Parent
while true do
wait(.01)
b.Rotation = b.Rotation + Vector3.new(0, 1, 0)
end
Its probably better to use CFrame and while wait(.01) do here is the overall result of the script.
local b = script.Parent
local rot = 0 -- Make a rotation variable
while wait(.01) do
rot = rot + .01 -- Make it add on every .01 second
b.CFrame = CFrame.new(b.CFrame.X,b.CFrame.Y,b.CFrame.Z) * CFrame.Angles(0,rot --[[set this to rot so it can rotate]] ,0)
end
--There you go!
Hope this helps!
The reason why it doesn't work is because you are adding +1 to the rotation each time.
On Roblox, when rotating a part, once the Y rotation gets to 85, it looks like this:
--This is what the rotation looks like if you add 1 to the Y value each time
0,85, 0
0,86,0
0,87,0
0,88,0
0,89,0
0,90,0
-180,89,-180
-180,88,-180
-180,87,-180
-180,86,-180
-180,85,-180
I don't know how to entirely explain this, but I'll fix your code.
local b = script.Parent
while true do
wait(.01)
b.CFrame = b.CFrame * CFrame.fromEulerAnglesXYZ(0,1,0)
end
Its better to use CFrame.Angles instead of fromEulerAnglesXYZ
It's the same thing, but whatever.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
You put "wait(.01)" which would require the script to wait 1/100 of a second but the quickest wait possible is 1/60 of a second which is "wait(0)"
I don't want it to rotate super fast :P
You were having it rotate 100 times a second which the roblox engine does not support, 1/60 is the shortest amount of time and "wait(0)" makes it wait 1/60th of a second.