NullReferenceException

Salut, j’ai un prob avec mon script, tout marchais bien mais quand j’ai fini mon script de game over (un autre script), mon script qui marchais avant ne marches plus et fait crash le jeu quand je récup mon coin.

Merci d’avance pour votre aide, et désolé je suis débutant ^^’

erreur: https://image.noelshack.com/fichiers/2019/46/2/1573514925-bug.png

Script: YouTube

Hello SunSet_Zyco,
First of all, please note that our forum is English only, so that everyone can pitch in and help each other.

For your issue, you are trying to use a variable which doesn’t contain any object. This is usually due to

  • Forgetting to assign a public variable visible in the inspector when selecting the game object
  • Calling GetComponent() on a game object which doesn’t have the component, and then using the result.

The error is coming from “CoinsBahavior”, on line 23. Have a look what kind of code you are using there, and feel free to post again if you have any additional questions. (But please try to use English next time).

1 Like