Free shiny gui object function

Want to add a simple shine effect like this to your gui objects?
Image from Gyazo (GIF)

Copy this function into your code and you’re done!

Function
local function shineLoop(guiObj, t)
	local clrSrcProperty = t.clrSrcProperty
	local shineWidthScale = t.shineWidthScale or 0.5
	local shineColor = t.shineColor or guiObj[t.clrSrcProperty]
	local shineBrightnessScale = t.shineBrightnessScale or 0.35
	local shineDurationSec = t.shineDurationSec or 0.75
	local shineIntervalSec = t.shineIntervalSec or 2
	local shineRotationDeg = t.shineRotationDeg or 15
	assert(guiObj and clrSrcProperty, "missing required argument to 'shineLoop()'")

	if guiObj:FindFirstChild("UIGradient") then
		warn(`there is a gradient inside of '{guiObj:GetFullName()}' that could interfere with 'shineLoop()'`) -- Warn if another gradient is going to interfere
	end

	guiObj[clrSrcProperty] = Color3.new(1, 1, 1) -- Make sure the gradient is the only source of color

	local gradient = Instance.new("UIGradient", guiObj)
	gradient.Color = ColorSequence.new({
		ColorSequenceKeypoint.new(0, shineColor),
		ColorSequenceKeypoint.new(.5 - shineWidthScale/2, shineColor),
		ColorSequenceKeypoint.new(.5, shineColor:Lerp(Color3.new(1, 1, 1), shineBrightnessScale)), -- Middle point of decreased saturation (shine)
		ColorSequenceKeypoint.new(.5 + shineWidthScale/2, shineColor),
		ColorSequenceKeypoint.new(1, shineColor),
	})
	gradient.Rotation = shineRotationDeg

	task.spawn(function()
		while guiObj.Parent do
			gradient.Offset = Vector2.new(-1, 0)

			local shineTween = TweenService:Create(gradient, TweenInfo.new(shineDurationSec), {
				Offset = Vector2.new(1, 0)
			})
			shineTween:Play()
			shineTween.Completed:Wait()

			task.wait(shineIntervalSec)
		end
	end)
end

Use it like this:

local textLabel = script.Parent
shineLoop(textLabel, {
	clrSrcProperty = "TextColor3"
})

Or with more configuration:

local textLabel = script.Parent
shineLoop(textLabel, {
	clrSrcProperty = "TextColor3",
	shineWidthScale = 0.5, -- Default
	shineColor = textLabel.TextColor3, -- Default
	shineBrightnessScale = 0.35, -- Default
	shineDurationSec = 0.75, -- Default
	shineIntervalSec = 2, -- Default
	shineRotationDeg = 15, -- Default
})
2 Likes
3 Likes

could post some showcase video?

2 Likes

Oh, sorry i dont saw the “X2”, i dont think would be a video :grin:

2 Likes