I want to make a time counting script with less words so that I can finish earlier. More specifically, the timer will never stop until a game is found.
Script:
local textLabel = script.Parent textLabel.Text = "Looking for: 00:01" wait(1) textLabel.Text = "Looking for: 00:02" wait(1) textLabel.Text = "Looking for: 00:03" wait(1) textLabel.Text = "Looking for: 00:04" wait(1) textLabel.Text = "Looking for: 00:05" wait(1) textLabel.Text = "Looking for: 00:06" wait(1) textLabel.Text = "Looking for: 00:07" wait(1) textLabel.Text = "Looking for: 00:08" wait(1)
We can use a loop for this:
local waitedTime = 0 local function getFormattedTime(timeToFormat) local flooredTime = math.floor(timeToFormat) local minutes = math.floor(timeToFormat / 60) local seconds = math.floor(timeToFormat % 60) local formattedMinutes = minutes < 10 and "0" .. minutes or minutes local formattedSeconds = seconds < 10 and "0" .. seconds or seconds local formattedTime = formattedMinutes .. ":" .. formattedSeconds return formattedTime end while true do textLabel.Text = getFormattedTime(waitedTime) -- wait(1) will wait for at least a second, but could be for any time longer than that, so we simply add the return value, which is the time waited, to the total waited time waitedTime = waitedTime + wait(1) end