I know, this question was already answered a lot here, and believe me, I've tried so many ways to fix that problem, but it occurs over and over again.
So basically, I'm trying to change e.g. money in my game, from a different script.
But as soon as I click the button, I get this error message. I think I'm doing anything fundamentally wrong here, but it also happens in my score script, but that is still working anyhow... But here is the error:
NullReferenceException: Object reference not set to an instance of an object
Score.ResetScore () (at Assets/Scripts/Score.cs:36)
And here are the Scripts that should work together.
Script 1:
void ResetScore()
{
GameManager gamemanag = GetComponent<GameManager>();
score = 0;
gamemanag.ResetQuestions();
}
Script 2:
public void ResetQuestions()
{
unansweredQuestions = questions.ToList<Question>();
}
That was the score script because it's a bit cleaner. This doesn't really work as it should as well and I have no Idea why...
I'm posting the full code on pastebin at the end.
Would be great if you could help!
Script 1: http://pastebin.com/raw/qvbFYd3x
Script 2: http://pastebin.com/raw/8gMzaagq