i’m trying to make a typewriter that uses UIGrandients to gradually reveal the text, like in Skyrim, when your sneak level increases, for example. This is how it looks right now, and suddenly being able to see the front of the text is very jarring. how can i fix this?
i am not the best with UIGradients. this is my first time actually scripting with them, so the solution might be obvious, and i’m just ignorant.
this is my script:
local tweenService = game:GetService("TweenService")
local text = script.Parent
local uiGradient = text:WaitForChild("UIGradient")
local val = text:WaitForChild("numberValue")
local connection
uiGradient.Transparency = NumberSequence.new(1)
local info = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local properties = {
Value = 1
}
local tween = tweenService:Create(val, info, properties)
local function updateGradient()
local minValue = math.min(val.Value, 0.999)
local maxValue = math.max(minValue, 0.001)
local keypoint1 = NumberSequenceKeypoint.new(0, 0)
local keypoint2 = NumberSequenceKeypoint.new(minValue, 0)
local keypoint3 = NumberSequenceKeypoint.new(math.min(maxValue + 0.1, 1), 1)
local keypoint4 = NumberSequenceKeypoint.new(1, 1)
local keypoints = {keypoint1, keypoint2, keypoint3, keypoint4}
table.sort(keypoints, function(a, b) return a.Time < b.Time end)
uiGradient.Transparency = NumberSequence.new(keypoints)
end
connection = val.Changed:Connect(updateGradient)
task.wait(5) -- wait for the player to load in
tween:Play()
tween.Completed:Once(function()
connection:Disconnect()
end)