Trying to make an image rotate. Why isn't this working?

Hey DevForum!
I’m trying to make an image rotate for some loading screen. I’m just wondering… what’s not working?

The image that’s supposed to rotate is the weird animal I’m circling with my mouse in the video above.

-- Turning Icon --
while wait (0.1) do
    TurningIcon.Rotation += 1
end

Thank you!

2 Likes

this post would definitely help!

2 Likes

Your code works, so there’s something with your GUI setup.

Is turningicon referenced properly?

etc:

local TurningIcon = script.Parent --path to your image

if so I’m not sure what would be causing the problem

2 Likes

The code itself is correct. Make sure TurningIcon is referenced properly. Does the output give any errors?

2 Likes

No errors, weirdly. I asked some friends and they didn’t have any idea either. + It is referenced properly.

It might be a studio error?

1 Like

Doubt it’s a Studio error.
Show the whole script. Without more context there is nothing else we can do.

1 Like
-- Variables --
local GUI = script.Parent
local Background = script.Parent.Background
local Overlays = script.Parent.Overlays
local TurningIcon = Overlays.TurningIcon
local Connecting = Overlays.StatusLabel

-- On Load --
GUI.Enabled = true

-- Connecting Label --
while wait (0.1) do
	Connecting.Text = "Connecting"
	wait(0.6)
	Connecting.Text = "Connecting."
	wait(0.6)
	Connecting.Text = "Connecting.."
	wait(0.6)
	Connecting.Text = "Connecting..."
	wait(0.6)
end

-- Turning Icon --
while wait (0.1) do
	TurningIcon.Rotation += 1
end
2 Likes

image

Your first wait() loop will never end. The second one (which rotates your image) won’t ever run.
Break out of the first while wait() loop. Also, use task.wait() instead.

If you need to do both at the same time, consider using coroutines or task.spawn().

3 Likes

The code is correct, here is some tips that could possibly help you:

Make sure that the image is actually visible on the screen, and that it’s not hidden or covered by other objects.
Check if the “TurningIcon” object actually exists in your game. You may need to double-check the spelling and capitalization of the object’s name.
Ensure that the script is actually running. You can add a print statement at the beginning of the script to check if it’s being executed.
If the image is a child of another object, make sure that the “Rotation” property is enabled for that object. You can do this by selecting the object in the Explorer window and checking if the “Rotation” property is present in the Properties window.

1 Like

first while loop yields the code and doesnt run the 2nd loop

try multi threading

What is multi-threading, if I may ask?