I am trying to use this script to set a timer for someone looting a player however i can't get it to reset after i call it a second time but it stores the original value of time left where as i want it to start fresh each time. i am calling it from another script which enables and disables it on the OnTriggerEnter and OnTriggerExit methods
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Changetext : MonoBehaviour { public float timeLeft = 5; public Text countdownText; public float cash = 0; // Use this for initialization void start() { timeLeft = 5; } void Update() { timeLeft -= Time.deltaTime; countdownText.text = ("Time Left = " + timeLeft); if (timeLeft <= 0) { countdownText.text = "You got the cash"; cash = 1; } } }