How to make a counting timer

i am now making a game that about escape room. And now, i wanna make a number clock that can count time in the game. Anyone know how to make it?

2 Likes

Hi @kit,

  1. Create a variable called “clock” and set it to the number of seconds required
  2. Add a repeat x times loop block with the clock variable value as the x parameter.
  3. Inside the loop block, put wait 1 second and change variable by block (1 or -1 depending on whether you want to increase or decrease)
  4. Set the text of your text object (your timer) to the value of your clock variable

Also see:

Hope that helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

2 Likes

hi there im just want to have a timer in my game that makes it to when the timer is up it ends the cospace and your restart but it also shows on your screen when you play

1 Like

you just need to add an “If”.

If clock variable is equal or less than zero, restartthe game.

image

2 Likes

Hi!
I want to change te ‘0’ in ‘klok’ image, just like on the image above from DaniYubero. B
ut when I drag the klok-block in this space, it changes to
image
Can you explain me how to do this?
Thanks!

1 Like

Hi @rdw

Just view this video, if you habe further problems answer tagging me please :wink:

2 Likes

Yes, that’s it! Thank you!

1 Like

I did this coding and it works completely fine. But because I added this none of my other coding is working anymore. How am I meant to keep the timer working and also keep my other coding working aswell?

1 Like

Hi @Winnie_Peasland You have to insert your code into a “Run Separatly” block.

Hope this help!

3 Likes

How do I make a score board so every time an object is clicked the score goes up by one.

1 Like

Hi @Winnie_Peasland,
you can either make a cospace property (in my opinion, better to use for a scoreboard), or you can make a variable with the count of the score. Here is an example of something similar to a scoreboard, this project has a stopwatch instead and will save on the next scene as well.

CoSpaces Edu :: Speedrunner v1

(all projects are remixable now so you should be able to look at the code)

Hope this helped!

3 Likes

How would the code look like if I was to do a property. Thanks for your help so far though!

1 Like