How to make blinking text

HELLO!!!
I was just with the UI design of my game but now I have a question, how would I do a depleted ammunition effect for my game, basically I want the text to change color repeatedly from red to its original color
as I would do it?

let’s just say (code varies from your logic)

local ammo_Instance = -- <location of instance and I may guess its a NumberValue>
local ammo_Text = -- <location of text>
local speed = 0.25
ammo_Instance:GetPropertyChanged("Value"):Connect(function()
    if ammo_Instance.Value == 0 then
        ammo_Text.TextColor3 = Color3.fromRGB(255, 0, 0)
        task.wait(speed)
        ammo_Text.TextColor3 = Color3.fromRGB(255, 255, 255)
        task.wait(speed)
        ammo_Text.TextColor3 = Color3.fromRGB(255, 0, 0)
        task.wait(speed)
        ammo_Text.TextColor3 = Color3.fromRGB(255, 255, 255)
    end
end)

1 Like

I was referring to color sequences, I know that the part where it changes would be done in a cycle, but I don’t know how to handle color sequences.
edit: i to use UIGradient

You can try giving the text an UIGradient object (With your prefered color for its ColorSequence property) and then use TweenService to tween its Offset property
image

1 Like

ohh I realize I shouldn’t use a loop? How do I change the offset property? a small code example?

local UIGradient = YourTextObject:WaitForChild("UIGradient", 10)
local TweenService = game:GetService("TweenService")

while true do
	local Tween = TweenService:Create(UIGradient, TweenInfo.new(1, Enum.EasingStyle.Linear), {Offset = Vector2.new(-1, 0)})
	Tween:Play()
	task.wait(1)
	UIGradient.Offset = Vector2.new(1, 0)
	local Tween2 = TweenService:Create(UIGradient, TweenInfo.new(1, Enum.EasingStyle.Linear), {Offset = Vector2.new(0, 0)})
	Tween2:Play()
	task.wait(2)
end

The Offset property determines the scalar translation of the gradient from the center of the parent GuiObject.
This is a simple way to tween the offset property of the UIGradient object, I hope this helped you!
Also you can see more from here:

1 Like
local info = TweenInfo.new(

script.Duration2.Value,

Enum.EasingStyle.Linear,

Enum.EasingDirection.Out,

100, 

true, 

0

)
if value == 0 then
local UIGradient = tewx.UIGradient
Tween = service:Create(UIGradient,Paramens,{Offset = Vector2.new(-1,0)})
Tween:Play()
elseif antvalue then --so that the function does not run if the Tween is not reproduced
Tween:Stop()
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.