Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I rotate an object inside of a GUI?

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

1 comment

0

I need to rotate an ImageLabel for about 30 seconds and then it stops rotating.

1 answer

✓ Accepted answer

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

2 comments

0

thanks!

0

This should be useful, never knew his.

This discussion is preserved as it was. New answers, comments, and votes are closed.