I guess you just don't understand what `NullReferenceException` means. So, if a variable isn't set to an object, then you need to do a simple piece of code:
void DoChop()
{
if (remainSlider) {
if (remainSlider.value != 0)
{
timer = 0f;
canChop = false;
remainSlider.value--;
remainingText.text = remainSlider.value.ToString();
}
} else {
Debug.Log("something has gone wrong");
}
}
This will use the debug log to tell you that `remainSlider` isn't set.
Now, also, you claim that every object has had `remainSlider` set correctly. So it would be trivial for you to check that this variable is set in the `Start()` function.
↧