How can I make this UIgradient go left to right transparency?

as the title suggests I want to kinda tween this UIgradient to go transparent left to right.
start1;

end1;

end2;

Easiest way is probably to tween 2 number values:

local tweenService = game:GetService('TweenService')

local uiGradient = script.Parent:WaitForChild('UIGradient')

local left, right = Instance.new('NumberValue'), Instance.new('NumberValue')

local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear)

local function update()
	uiGradient.Transparency = NumberSequence.new(left.Value, right.Value)
end

left.Changed:Connect(update)
right.Changed:Connect(update)

while true do
	local leftUp = tweenService:Create(left, tweenInfo, {Value = 1})
	leftUp:Play()
	leftUp.Completed:Wait()
	local rightUp = tweenService:Create(right, tweenInfo, {Value = 1})
	rightUp:Play()
	rightUp.Completed:Wait()
	local leftDown = tweenService:Create(left, tweenInfo, {Value = 0})
	leftDown:Play()
	leftDown.Completed:Wait()
	local rightDown = tweenService:Create(right, tweenInfo, {Value = 0})
	rightDown:Play()
	rightDown.Completed:Wait()
end
2 Likes