NullReferenceException[SOLVED]

So I haven’t used Photon before, but I’m following a tutorial and the documentation. (The tutorial is for making players connect, etc.) I am getting a NullReferenceException: Object reference not set to an instance of an object error.

I’ll post hastebins if you can help me out. The lines will be marked with where the error is taking place. I’ve been trying to figure this out but i can’t.

https://hastebin.com/icipevodip.cs // player movement script
https://hastebin.com/vewemomuhu.cs // weapon switching script
https://hastebin.com/fodikiduzi.cs // pistol script

The reason I did hastebin was because some of these scripts are long. I feel like this error is happening because it’s always thinking that the player isn’t my player and is just returning false. If you guys need more help, I am using Dani’s player movement script that he made. This has two scripts, one for the head and then the actual movement. The rest is my code. I’m just really confused and im trying to fix it.

Whatever you might be doing in Photon is irrelevant here. This is just a nullref, which means one of your variables has not been initialized. The error tells you which line it is on. Identify where that variable is SUPPOSED to be initialized, and see why it might be failing. If you cannot find where it is initialized then you are missing the initialization step, and you must provide one.

1 Like

ill try something. thank you