How would I make a UIGradient Rotate?

Hi Devs! I have had a problem with a rotating gradient script. Please have a read and tell me if there is an error in my script!

  1. What do you want to achieve? I want to make a UIGradient rotate in the background of a frame. The UI is this:
    image
    The light blue and darker blue lines are the gradient by the way!

  2. What is the issue? I have been using a while true do loop but it didn’t work.

  3. What solutions have you tried so far? I was looking around here if anyone else ever experienced it then looked on the DevHub and then looked on YouTube but nothing helped me. :sad:

My script:

local Rotation = true

while true do
	script.Parent.UIGradient.Rotation = script.Parent.UIGradient.Rotation + 5
end

Thanks for all help and support!
Regards, Flash!

Edit: The gradient is also supposed to continuously rotate

1 Like

Fixed the problem with a repeat loop and a function:

function rotateGradient()
	wait(0.05)
	script.Parent.UIGradient.Rotation = script.Parent.UIGradient.Rotation + 1
end

repeat rotateGradient() until 1 == 2