How to make Text Cycle on HUD?

I want to make a bar at the top that shows text, the text fades in, stays for like 3 seconds, then fades out…

And it shows multiple text variables… how could I make this? I know how to make the HUD and everything, just don’t know how to make the text fade in and out.

Well, try making a table with multible text variables, then add a timer running for 3 seconds then fading.

I know that… but what would the code look like

Make a table containing all the different texts, then randomly select one item in the table and change the alpha of the color with a variable that decreases and increases over time


 	local TextCycle = {
	"Welcome to our server!",
	"Visit our website at website.com"
	}
	timer.Create("timer1", 3, 0, function()
	ShowText = table.Random(TextCycle)
	end)
	
	surface.SetDrawColor( 48,48,48, 225  )
	surface.DrawRect( 0, 0, ScrW(), 26 )
	
	draw.DrawText(ShowText, "TargetID", (ScrW() / 2) - 25, 3 , Color(255,0,0,0),0)


This is what I have so far… but it isn’t working how I want it to. What can I do to fix it?

Timers are horrible for this job, I have a similair thing for my gamemode:
[lua]
Placed in a think:
if CurTime() > RANDOM_TIME then
local notis = math.random(1,#RANDOM_NOTIFICATIONS)
if notis != OLD_NOTIFICATION then
NOTIFICATION = RANDOM_NOTIFICATIONS[notis]
OLD_NOTIFICATION = notis
else
if notis+1 > #RANDOM_NOTIFICATIONS then
NOTIFICATION = RANDOM_NOTIFICATIONS[notis-1]
OLD_NOTIFICATION = notis-1
else
NOTIFICATION = RANDOM_NOTIFICATIONS[notis+1]
OLD_NOTIFICATION = notis+1
end
end
RANDOM_TIME = CurTime() + 50
end

– and this in the hud drawing
if CurTime()+10 > RANDOM_TIME then
if CurTime() >= randAlphaUpdate + 0.01 && !(randAlpha <= 0) then
randAlpha = randAlpha - 1
randAlphaUpdate = CurTime()
elseif randAlpha <= 0 then
randAlpha = 0
end
else
if CurTime() >= randAlphaUpdate + 0.01 && !(randAlpha >= 255) then
randAlpha = randAlpha + 1
randAlphaUpdate = CurTime()
elseif randAlpha >= 255 then
randAlpha = 255
end
end
draw.DrawText(""…NOTIFICATION…"", “Trebuchet24”, w0.990, h0.010, Color(255, 255, 255, randAlpha), 2)
[/lua]

I’m not gonna spoonfeed you all code doesn’t fit in there, and all the globals that have to be assigned. But there you got an example.