I want to make an object fully rotate, so im doing a script like this
brick = Instance.new("Part", game.Workspace) brick.Name = "Hello" brick.Size = Vector3.new(4,4,6) brick.Position = Vector3.new(1, 19, 1) brick.Anchored = true brick.Rotation = Vector3.new(0.2,0,0) wait(0.1) brick.Rotation = Vector3.new(0.4,0,0) wait(0.1) brick.Rotation = Vector3.new(0.6,0,0) wait(0.1) brick.Rotation = Vector3.new(0.8,0,0) wait(0.1) brick.Rotation = Vector3.new(1,0,0) wait(0.1) brick.Rotation = Vector3.new(1.2,0,0) wait(0.1) brick.Rotation = Vector3.new(1.4,0,0) wait(0.1) brick.Rotation = Vector3.new(1.6,0,0) ...
But, I want to make it like a pattern so I don't have to make it 1 by 1. I thought of something that would take the number in the line before and then add 0.2. so it goes like Vector3.new(0.2,0,0) and then is (0.2,0,0) and keeps adding to until it fully rotates.
Do you mean like a loop?
for Num = 1, 360/0.2 do brick.Rotation = brick.Rotation + Vector3.new(0.2, 0, 0) wait(0.1) end --[ This is a *For* loop, for loops can be used in many ways, as they stop once "Num" reaches the second number (which I have put as division (360/0.2), once Num reaches the limit specified, the loop will stop and your brick should have rotated one full 360 degree turn. ] --With that in mind, if you want the brick to rotate infinitely, just do: while true do brick.Rotation = brick.Rotation + Vector3.new(0.2, 0, 0) wait(0.1) end --[ This is a *While* loop, while loops are infinite, unless you put in the break command, which ends any loop, no matter if its a For or While; NEVER set a While loop with no wait() in it, this may cause your game to crash as it will devote all of its processing power to computing that loop as fast as possible with no break. ]
Hope that helps, if this doesn't work, hopefully someone else will answer your question the way you need. Regards, Xetrax
I think you are trying to say you want to do it without writing so many lines I guess.
Try doing a while
loop, then inside the loop, add the rotation by how much you want.
Don't forget to use wait
, or your part won't work!