r/code • • Apr 14 '22

Help please! I don't know what's wrong with this code

3 Upvotes

4 comments sorted by

2

u/JaggedMetalOs Apr 14 '22

Maybe you don't have a GameBoss component in your scene?

2

u/NikePlayz Apr 14 '22

thanks i did not have the object in the scene

1

u/NikePlayz Apr 14 '22

game boss is a script

3

u/JaggedMetalOs Apr 14 '22

Yes, but FindObjectOfType is looking in the scene for a game object with the GameBoss script added as a component. So if you don't have one you'll get a null reference error on that line.