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

How do I rotate an object inside of a GUI?

Asked by 7 years ago

How do I rotate an object inside of a GUI? (Image, button, etc..) I want it to repeat rotate until stopped (20-30 seconds)

0
I need to rotate an ImageLabel for about 30 seconds and then it stops rotating. IfIWasntSoSwag 98 — 7y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

All GuiObjects have a Rotation Property. You can increment this Property in a numerical for loop to make a spin animation.

local guiObject = script.Parent --Object to rotate
local incr = 1;

for i = 1,360 do
    guiObject.Rotation = guiObject.Rotation + incr
    wait()
end

If you want to continue this animation for 30 seconds, you can use the tick function to decide how much time has passed.

local guiObject = script.Parent --Object to rotate
local incr = 1
local Then = tick() --Time before it started rotating
local limit = 30  --Amount of time it should spin

while Then - tick() < limit do --Only animate within time limit
    for i = 1,360 do
        guiObject.Rotation = guiObject.Rotation + incr
        wait()
    end
end
0
thanks! IfIWasntSoSwag 98 — 7y
0
This should be useful, never knew his. FiredDusk 1466 — 7y
Ad

Answer this question