Also, How would i make an if statement to check if my enemy gameobject is destroyed?
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Score : MonoBehaviour { public Text scoreDisplay; public int score = 0; public Enemy Enemy; // Update is called once per frame void Update() { scoreDisplay.text = "SCORE:" + score; } public void IncreaseScore() { if(Enemy == null) ; { score += 1; } } }
NO! You are NOT stupid.
This is an extremely common mistake. It's one you will probably make at least once on every project (multiple times for larger projects). Everyone does. It's one of many simple errors you learn to look for first so you can fix it before tweaking your code.
If you only take one thing from this experience, I want it to be learning to not get down on yourself for making simple errors and mistakes; they aren't character flaws, they're just a part of the task. NO ONE writes perfect code the first time, every coder uses a debugger.