Home > Back-end >  I'm trying to use a code to display score in the UI text but it didn't show up/change the
I'm trying to use a code to display score in the UI text but it didn't show up/change the

Time:08-05

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    
    public class wastafel : MonoBehaviour
    {
        public Text ctText;
        public static int iscucitangan;//scoring
        public int handwash;
    
        void update()
        {
            handwash = iscucitangan;
            ctText.text = "Sudah cuci tangan :"   handwash;
        }

 }

I tried this script to display a scoring system I made in unity (I use this video as reference : https://www.youtube.com/watch?v=YKeXyaB41EA). I applied this code to a text UI object in my program like this. This is the CT text object. But when I press play, it came up like this, no change at all. This is my text setting. Is there something that I miss?

CodePudding user response:

It is caused because of the typo, it should be Update() with a capital U and not update().

CodePudding user response:

First thing first, have you assigned ctText in inspector? Then... how is your scoring variable being updated?

  • Related