I've just made a score for my game, and I've tried to do that when you get to a certain score you'll get to the next level, I haven't done the next step code yet but it's irrelevant at the moment. I'm having a CS0029 error, line 31. Please help me. Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; public class scoreactive : MonoBehaviour { public Text MyscoreText; private int ScoreNum; public int ScoreTarget; // Start is called before the first frame update void Start() { ScoreNum = 0; MyscoreText.text = "" + ScoreNum; } private void OnTriggerEnter2D(Collider2D Hexegon) { ScoreNum += 1; MyscoreText.text = "" + ScoreNum; } void FixedUpdate() { if(MyscoreText.text = ScoreTarget) { } } }
You have used = which means you are providing value which is rising error. You need to use == which means you are checking if your current score if equal or not Use this instead -> if(MyScoreText.text == ScoreTarget) { // Your Code Here...... } Also Checkout this Channel I will be posting more unity tutorial videos for beginners https://www.youtube.com/channel/UCZgDptjLIunBulmt2mkxJSw