Hello, devs!
I made a dynamic timer that counts up, and after certain points in time, the timer’s text is updated.
As well as being a nightmare to debug, this code runs horribly and inefficiently due to all the elseif statements. I was wondering if there was a more efficient way to do this, one that isn’t an eyesore.
Prepare yourselves mentally:
local function renderSplash()
if ransplash == splashes[10] then
while wait() do
if math.round(time()) < 59 then
splash.Text = "You've been here for "..math.round(time()).." seconds!"
elseif math.round(time()) <= 119 then
splash.Text = "You've been here for ".. math.round(time()) / 60 .." minute!"
elseif math.round(time()) >= 120 then
splash.Text = "You've been here for ".. math.round(time()) / 60 .." minutes!"
elseif math.round(time()) >= 3599 then
splash.Text = "You've been here for a really long time!"
end
end
else
splash.Text = ransplash
end
end
Is there a way to do this more efficiently? How should I make this better?