I want to rotate not only Y axis but X too
brick = Instance.new("Part", game.Workspace) brick.Name = "Hello" brick.Size = Vector3.new(4,4,6) brick.Position = Vector3.new(1, 28.9, 1) brick.Anchored = true for Num = 1, 360/0.2 do brick.Rotation = brick.Rotation + Vector3.new(0.2, 0.0, 0) wait(0.05) 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:
In this script, Y axis will rotate until it reaches 360 degrees, but I want to make the X axis turn 140 degrees at the same time
This is actually a somewhat complicated problem. The obvious way is to use coroutines to make the two loops run at the same time, but that has the problem of getting them in sync.
The way I would solve this is to use a different style of loop:
brick = Instance.new("Part", game.Workspace) brick.Name = "Hello" brick.Size = Vector3.new(4,4,6) brick.Position = Vector3.new(1, 28.9, 1) brick.Anchored = true local startTime = tick() local elapsedTime = 0 local rotTime = 90 -- in seconds -- This is equivalent to (360/.02)*.05 local desiredRot = Vector3.new(140, 360, 0) -- This is how much the block will rotate about each axis over the 'rotTime' while elapsedTime < rotTime do elapsedTime = tick() - startTime if elapsedTime > rotTime then elapsedTime = rotTime -- so that it doesn't go over. end brick.Rotation = desiredRot*(elapsedTime/rotTime) wait() end
Easy, change you vector3 (0.2, 0.0, 0.0) to (0.2, 0.2, 0.0)
brick.Rotation = brick.Rotation + Vector3.new(0.2, 0.2, 0.0)