Can't assign the sword script to Player

As the title says, I’m not able to attach the sword script to the Fighter script located on the player. When I try Unity displays this error pop up:

image

I followed Rick like a hawk, and I’m not really sure what I’m missing, and its going to be so annoying/ satisfying once it’s figured out! Can anyone help?

Check if your script name in inspector and class name in the same file are the same

1 Like

So for this lecture, there is no class. In script Weapon.cs, Rick informed us we are not using monobehaviour instead we were going to make a script that uses “CreateAssetMenu”.

But you still helped me figure it out, the issue was I added and “S”, weapons.cs which is incorrect.
In the script “Fighter.cs” you’re calling for “weapon”… so I re-labeled the script to “weapon.cs” and deleted the “Sword script object” from my sword folder and recreated it, and now everything works!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms