I don’t see any code here that would cause a null ref, so the error is probably from something else. Hard to say as you haven’t posted the full error.
Nonetheless null refs are always the same: https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/
Also remember to use code tags next time: Using code tags properly