I know this question has been asked before, here and here.
But I still can't get variables from another script. I don't know what I'm doing wrong.
*(I'm really new to programming in general so I might have missed something glaringly obvious)
I keep on getting the error: The name 'points' does not exist in the current context
The slimespawner script is on the Canvas.
Sorry if the question is too simple.
here's the script I'm trying to access:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class slimespawner : MonoBehaviour
{
public int points;
public Text score;
public float xx;
public float yy;
void Start()
{
points = 0;
xx = Random.Range(-32f, 32f);
yy = Random.Range(-18.5f, 18.5f);
}
void Update()
{
score.text = "Score: " + points.ToString();
}
}
And here's the script that's trying to use the points variable.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class slimecontroller : MonoBehaviour
{
private float movespeed = 0.1f;
public slimespawner slisp;
void Start()
{
slisp = GameObject.Find("Canvas").GetComponent<slimespawner>();
}
void Update()
{
points += 1;
}
}