I am trying to create a shine effect for my ImageLabels. I know I can use Shime, but it doesn’t work with ImageLabels, so I’m looking for an alternative solution.
I have attempted scripting it myself, but it’s not working, and it’s only confusing me more. Could someone help me figure out how to create a shine effect for my ImageLabels?
Most of the time, when I create something complex for my game, it would be great to have an nice shine effect on my Image Label UI.
local ShineModule = {}
local TweenService = game:GetService("TweenService")
function ShineModule.ApplyShine(element, duration, loop, delayTime)
if not element then return end
local Shine = game:GetService("ReplicatedStorage"):WaitForChild("Templates"):WaitForChild("UI"):WaitForChild("Shine"):Clone() --shine frame
local Gradient = Shine:FindFirstChild("UIGradient")
Shine.Parent = element
local ShineGoal = {Offset = Vector2.new(0, 2)}
local ShineTweenInfo = TweenInfo.new(duration or 1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut, 0, false, 0)
local tween = TweenService:Create(Gradient, ShineTweenInfo, ShineGoal)
if not Gradient then
return
end
if loop then
task.spawn(function()
while true do
tween:Play()
task.wait(math.random(delayTime, delayTime * 3)) --random delay
Gradient.Offset = Vector2.new(0, -2)
end
end)
else
tween:Play()
end
end
return ShineModule