Rotating Gradient Not Looping

Hello, I have a gradient around my play button, it rotates around 360 but then stops and I am unsure how to make it loop inside the code. I followed a tutorial but it does not seem to work. Help please!

image

Here is the localscript

local UIGradient = script.Parent.UIGradient
local tweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
local tween = tweenService:Create(UIGradient, tweenInfo, {Rotation = 360})

tween:Play()

Here is the link to the tutorial I followed: https://www.youtube.com/watch?v=AHqGlQtxPDQ

1 Like

You’re better off making a loop that just increments the rotation by 1 every second or so.

How would I do this exactly???

while true do
UIGradient.Rotation += 1
task.wait(.1)
end

note: i i recommend you wrapping into a task.spawn function so it doesn’t halt the entire code

You have to fill out the entirety of TweenInfo’s given arguments, in the end theres a “RepeatCount” argument in which you can set to -1 for it to infinitely rotate.

TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,-1)

Like so.

Where do I put this exactly? I put it at the end of my localscript just in case and it did not work

I have no idea what you mean by wrapping into a task.spawn function

Would I just put this at the end of the localscript?

Hey,

You need to loop the tween in the TweenInfo
Here’s how you’d do that:

local UIGradient = script.Parent.UIGradient
local tweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear Enum.EasingDirection.In, -1)
local tween = tweenService:Create(UIGradient, tweenInfo, {Rotation = 360})

tween:Play()

By changing the TweenInfo “repeat count” to -1, we loop the tween indefinitely.

Just replace the tweeninfo you created in the variable for your tweeninfo.

Doing this there are lot’s of the red line errors and it make the rotation not even move the first time

I must have mistyped something, can you paste the errors here real quick?

Can you give an example of what it would look like? Sorry I’m awful at understanding code

local UIGradient = script.Parent.UIGradient
local tweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear,Enum.EasingDirection.In,-1)
local tween = tweenService:Create(UIGradient, tweenInfo, {Rotation = 360})

tween:Play()
1 Like

I forgot a comma

local UIGradient = script.Parent.UIGradient
local tweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1)
local tween = tweenService:Create(UIGradient, tweenInfo, {Rotation = 360})

tween:Play()
1 Like

@CMan_real @SkibidiVonKoo Both of these worked perfectly, thank you so much!

1 Like

No problem, have a great Monday!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.