Can someone help me make a countdown timer for C#,I just need help making a countdown timer

Every time I walk over a specific trigger a countdown should show up. Once it reaches 0 the game should refresh and start from the beginning spawn.,Every time I walk over an Object a countdown would be displayed. At the end of the countdown the screen would refresh, and everything would go back to normal. The timer should only pop up once a specific item has been collected.

I’m going to post unpopular posts, like the unpopular guy I am. From your question / request (I might be totally wrong here) but it looks like you have next to zero knowledge about coding / solving coding and logic problems. I would recommend you to take some courses in Unity / C# coding courses for beginners and work out from that.

From what I am understanding here it seems as if you are starting in the wrong end. You can do what you want, but I strongly suggest that you can’t go about implementing code and getting others to write it for you unless you know what you are doing. You’ll never learn to solve problems, you’ll never learn to write code and you’ll have a s**tty time trying to learn gamedev, because this is hard work, and there is no shortcuts that’s gonna pay out for you. And if you struggle, I strongly recommend you to find a teacher.

I am telling you this because this is where I started, I started in the wrong end, and I wish I had someone to tell me this before I spent years before cracking the code the right way. Coding can be easy if done the right way, but it can be near impossible if done the wrong way. @Salkaver

try this :

 using System.Collections;
    using UnityEngine;
    using UnityEngine.UI;
    
    public class CountdownTimer : MonoBehaviour
    {
        public float countdownTime = 10f; // The initial countdown time
        public Text countdownText; // The UI text to display the countdown
        public bool collecteditem; // The item that needs to be collected to activate the countdown
    
        private bool countdownStarted = false;
        private float currentTime = 0f;
    
        private void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.CompareTag("Player") && collecteditem)
            {
                // Start the countdown if the player enters the trigger and the collectible item has been collected
                countdownStarted = true;
                currentTime = countdownTime;
                countdownText.gameObject.SetActive(true);
            }
        }
    
        private void Update()
        {
            if (countdownStarted)
            {
                // Decrement the countdown time and update the UI text
                currentTime -= Time.deltaTime;
                countdownText.text = Mathf.RoundToInt(currentTime).ToString();
    
                if (currentTime <= 0f)
                {
                    // Reset the player position and stop the countdown when it reaches zero
                    countdownStarted = false;
                    countdownText.gameObject.SetActive(false);
                    currentTime = 0f;
                    collecteditem = false;
                
                }
            }
        }
    }