How to script a scoreboard clock

Note I do not know much of how to do this so bear with me if I ask a lot of questions

Hello All! I am here today to ask for some scripting support.

I am trying to make an NCAA Football Scoreboard.

My Current Scoreboard

I need help controlling the play clock and the regular clock. Controlling the play clock is easy but its the regular clock because it’s in another format like 1:00.

I need help counting it down all the way to 0:00.

This also has to change on everyone’s screen so it must use remote events and :FireAllClients.

If anyone can help it would be greatly appreciated!


1 Like

What do you have so far? I think people are happy to help but we don’t want to do it for you because that wouldn’t be helpful to you or are you just looking for advice?

This has been asked before, please seach before asking:

1 Like

I have nothing because I dont know what I should do.

First off, I would learn how to do basic scripting (good tutorials: then you can try to make this. All you really need is a for loop that counts down every second. (plus a function that converts seconds to the 0:00 format thingy, @colbert2677 posted about this below my post) Good luck on your game! :wink:

Confused as to what you’re looking for. Are you trying to get the 0:00 format for time? Manage your time in seconds and then format it down to a MM:SS format.

local currentTime = 600
local minutes, seconds = math.floor(currentTime/60), currentTime%60

local timeString = string.format("%d:%.2d", minutes, seconds)
-- Send it over or set it
print(timeString) -- 10:00

This takes your time and applies various equations to it. With 60 seconds in a minute, we can use this two ways:

  • Find out how many whole minutes are formed from the current time, then shed off extras by rounding down
  • Find out how many chunks of 60 fit into the number as a whole until a number below 60 exists, then return that number (modulus)

We then format that into a string using string patterns and string.format. The first case, %d, tells us to accept a number into the string. The second case, %.2d, tells us to accept a number BUT add 0s if it’s below a certain number. This is called zero padding. A number below 10 will return 0n and a number 10 or above returns the raw number.


I am trying to make a GUI that when I click a button the timer will start to run. 5:59, 5:58 and so on. Then I am making a button to stop it. This needs to change on every ones screen.

Refer to what I just posted, as it does exactly what you asked for in terms of getting the time format. I just don’t have countdown code here. Handle all game time in seconds. When counting down, just subtract one second and format it as necessary.

My code sample uses 10 minutes (600 seconds); just change the 600 to 360 seconds (6 minutes) for your round timer and apply my code (getting minutes and seconds from time, formatting them to 0:00 format).

I don’t know what else you’re asking for. Are you asking for the countdown code too? That’s not something I’ll give. You should try figuring this out on your own.

1 Like

Making a number go down is simple, you could use a NumberValue and TweenService and make the tween decrease the number from how much to 0.
Or you could use a numeric for loop, the start being how much & the end being 0. You won’t need to include the increment as the default is 0.

Firing all the clients to see the change could be very inefficient, instead I’d say use a StringValue which is situated inside ReplicatedStorage.
Then inside the gui have a LocalScript which connects on .Changed of this StringValue and sets the new value to the gui. Remember that the parameter is the new value if the .Changed event is on a ValueBase.

I need help making it appear in all clients

There are many ways to do this. If you want an absolute beginner’s way to do this, refer to the post above your own. The solutions to your problems are being posted: take some time to digest the information and apply it to your system.

Keep the seconds value in an IntValue in ReplicatedStorage. When the server is modifying time, make it set the value of that IntValue. The client will then connect to the Changed event of the IntValue object and format the time using my code sample above.

In your Gui, wherever you have that time TextLabel placed, you will assign its text to the timeString variable.

1 Like

I really do need help just decreasing the time by 1 and then changing it on all clients.

Because I am having trouble trying to create a countdown system with your code.

I use a numerical for loop:

for i = TotalTime, 0, -1 do
   time = i

Then you can use this to covert time to a h:m:s format:

Also just an FYI. You should try googling your question before asking here. You’ll find what you’re looking for faster if it’s out there.

Trouble in what sense? Details are required to actually address the issues you’re having. Have you actually read the posts and tried applying them to your work? What does your current implementation look like? Share the code responsible for counting down and formatting.

Considering what you said in the OP,

I made the assumption that you knew how to count down a timer, whatever control means. I’ve given the answer for this several times over now.

Handle your game time in seconds in any regard. When it comes to clients needing to.display that time, apply my formatting code. Don’t copy and paste it; actually modify it so it fits your system. Do some debugging on your own as well.

I just cant figure out a way to create sometime to countdown using your code.

Okay so I worked up a for loop

for i = currentTime, 0, -1 do

Its just using timeString I get an error and then used currentTime it spits out 359,358 and so on. How do I make it work with timeString?

You don’t figure it out. It’s meant to be a formatting example. Nowhere in this code is there anything in regards to counting down, tbe expectation was that you filled that out yourself.

Start your game timer at a certain amount of seconds. If you don’t know what minute-to-second conversion is, take a number for minutes and multiply it by 60 to get a representation of minutes in seconds (6*60 - 360 seconds). Count this number down and store it in an IntValue. He the client to connect to it’s Changed event and then apply my formatting code. Use the string you get at the timeString variable and set it as the text of the TextLabel.

-- Server (Script, ServerScriptService)
local gameTime = 6*60

local tracker ="IntValue")
tracker.Name = "GameTime"
tracker.Parent = game:GetService ("ReplicatedStorage")

-- Artificial initial buffer

while gameTime > 0 do
    gameTime = gameTime - 1
    tracker.Value = gameTime

--[[ With a for loop instead of a while loop
for i = gameTime, 0, -1 do
    tracker.Value = i

-- Client (LocalScript, StarterPlayerScripts)
local tracker = game:GetService("ReplicatedStorage"):WaitForChild("GameTime")

tracker.Changed:Connect(function (newTime)
    local minutes, seconds = math.floor(newTime/60), newTime%60
    local timeString = string.format("%d:%.2d", minutes, seconds)
    -- Up to you to figure this out
    (TextLabelPathHere).Text = timeString

I should not really have had to provide that for for you, as all the posts here have explained how to do this several times over. If you aren’t familiar with programming or don’t understand, please ask questions about the post rather than trying to ask for the code to make this work.

You should also put some (or more) time into learning how to code so these small issues can be resolved by yourself. Searching before posting is also important; there are many helpful finds on the DevForum, Developer Hub and the Toolbox.

This is as far as I’m willing to handhold, with the code above. Anything further, please refer to my posts as I have explained this process at least three times now. I won’t a fourth time.


Could explain what this does if you dont mind?

We begin with the server-side.

It initialises a variable, gameTime, which represents your game time - the intention is in the variable name. It does a quick equation to resolve minutes to seconds by the formula n*60.

Assuming you don’t make your own value, it makes a tracker in ReplicatedStorage that the game time gets assigned to. This object is replicated to the client without the use of remotes, so we can directly access the time value.

The artificial buffer is just part of the sample code that waits one second before starting the game loop. Then, while the time is not 0, it counts down. There is an alternative version commented out that works with a numeric for loop.

Now, we move to the client-side.

The client listens for every change to the value and then gets what the IntValue’s value was changed to. We then apply formatting to that number and set the Gui’s text to that formatted string. The explanation for the string formatting, I have already provided before.

Please read this carefully and apply it to create a system. This is merely sample code, you are not supposed to use this whole thing as the basis for your game. If anything breaks with this code, that’s on you.