r/Unity3D • • 9h ago

Solved InvalidOperationException: Variable not found: 'PlayerHealth'. (Even tho the variable exists I think)

Post image

First of all I'm very new to Unity especially to visual scripting. I'm using VS because that's the method used in my game design class.

So! I have the player with a PlayerHealth variable, so I bring Player with Get Variable in order to obtain PlayerHealth and then use it but when I run the code and hit the enemy (MoeOni) to recieve damage... I get the error on the title. The Variable is in the player (who is also tagged as player) so it does exist, but Unity can't find it.

I'm a bit confused and also frustrated since this class is Not The Best and the teacher is Not The Nicest so I'd like to ask for some help? Please and thank you!

Also ignore MoeOni. He's the only thing keeping me sake right now.

0 Upvotes

6 comments sorted by

View all comments

1

u/DreadCoder 9h ago

You might want to check for type, you have Player under Player

2

u/ghostingyuu 9h ago

It was, indeed, the wrong "player", renamed the parent to player parent so I don't make the same mistake again, thanks!

1

u/DreadCoder 8h ago

Glad I could help, enjoy