develofied
(develofied)
February 17, 2025, 3:51pm
#1
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!
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.
develofied
(develofied)
February 17, 2025, 3:55pm
#3
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.
develofied
(develofied)
February 17, 2025, 3:57pm
#6
Where do I put this exactly? I put it at the end of my localscript just in case and it did not work
develofied
(develofied)
February 17, 2025, 3:58pm
#7
I have no idea what you mean by wrapping into a task.spawn function
develofied
(develofied)
February 17, 2025, 3:58pm
#8
Would I just put this at the end of the localscript?
CMan_real
(CMan)
February 17, 2025, 3:58pm
#9
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.
develofied
(develofied)
February 17, 2025, 3:59pm
#11
Doing this there are lot’s of the red line errors and it make the rotation not even move the first time
CMan_real
(CMan)
February 17, 2025, 4:00pm
#12
I must have mistyped something, can you paste the errors here real quick?
develofied
(develofied)
February 17, 2025, 4:00pm
#13
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
CMan_real
(CMan)
February 17, 2025, 4:01pm
#16
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
develofied
(develofied)
February 17, 2025, 4:03pm
#17
@CMan_real @SkibidiVonKoo Both of these worked perfectly, thank you so much!
1 Like
CMan_real
(CMan)
February 17, 2025, 4:03pm
#18
No problem, have a great Monday!
1 Like
system
(system)
Closed
March 3, 2025, 4:04pm
#19
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.