How to use typescript? 🇪🇦

Good afternoon,
I have a countdown in typescript format, I would like to know how can I make the countdown start and end with an interaction with a coblocks carácter?

let textItem = Scene.getItem("YPu7Q7uO") as TextItem
let cubeItem = Scene.getItem("h7hnd1Yv") as Cuboid

// Declaramos una variable que vamos a utilizar para almacenar el tiempo restante
let timeRemaining: number;

// Declaramos una variable que vamos a utilizar para almacenar la cuenta atras presente
let currentCountdown: Disposable = null

// Creamos una función que se encargará de actualizar la cuenta atrás
function updateCountdown(): number {
// Decrementamos el tiempo restante en un segundo

    // Si el tiempo restante es mayor o igual a 0, actualizamos el contador en el objeto TextBillboard
    if (timeRemaining >= 0) {
        textItem.text = timeRemaining.toString()
    // Si el tiempo ha llegado a 0, detenemos la cuenta atrás y mostramos un mensaje
    else {
        textItem.text = "Cuenta atrás finalizada!"
        return 1

if ( {
    if (currentCountdown != null) {

    timeRemaining = 60.0

    //actualizamos el contador en el objeto TextBillboard
    textItem.text = timeRemaining.toString()

    // Ejecutamos la función cada segundo para actualizar la cuenta atrás
    currentCountdown = Time.scheduleRepeating(updateCountdown, 1.0)

I would like the countdown to start when the question is answered with a yes. And finish either when you have the answer and answer with another questionnaire, or when it reaches 0, if it reaches zero I want you to say that you have lost and return to the starting scenario.


Hi @tifany_Dominguez ,

Unfortunately, I do not know how to code this in typescript, therefore I only know how to do this in coblocks. Here’s a way you can do this with coblocks.

first making the countdown work in a text box would look like this;
(you can set the time variable to the desired seconds beforehand)

You can make this a function command and run it when the player answers yes. You can also put the command “go to scene” block if a player answers wrong or the timer reaches zero simply by adding a “if” block to check if time is zero or not.

Hope this helped!


I have an example cospace so that you can have an idea of what to do: