Invalid call. Nonexistent function 'heal' in base 'Nil'

Godot Version

4.2

Question

Invalid call. Nonexistent function in base

Hi everyone,

First time posting here, sorry if this is the wrong place.

I’m getting the following error in my code, I’ve been trying to figure it out for a few hours now but it’s set up exactly the same as another section of my game so I’m not sure what’s going on anymore!

Error:

Invalid call. Nonexistent function ‘heal’ in base ‘Nil’

I’m using a global script Instants.gd to filter through cards in my game, and then activate the cards effects. I was trying to call the function from each card’s script originally but I couldn’t get it working with my limited exp in godot, so moved to using this singleton instead.

Unfortunately it looks like the Instants script isn’t picking up the CharacterStats like the other scene.

Instants.gd script:

u/export var char_stats: CharacterStats

func _heal(value): #blessing_of_the_clearing:

char_stats.heal(value)

I’m not sure why the char_stats var is returning Null in this script, but my “campfire” scene & script seems to be set up identically but are working just as intended.

I suspected the Instants script needed to be attached to a node in it’s own scene to be able to link the u/export
in the inspector, but that hasn’t worked on testing either.

Hopefully this is an obvious fix for someone with more experience!

Your function is named _heal. You are attempting to call heal(value), without the leading underscore, somewhere in your script. Call _heal(value) instead.

Regards,

1 Like

Thanks for the reply! It’s inconsistent, but the char_stats script doesn’t have the underscore. I’ll update it now.
I’ve made some progress since, I reformatted the script to use a signal to pass the character stats over and it is picking up the data now
Unfortunately though It’s running through the heal process twice…
I don’t want to burden anyone with reading through my messy scripts unless I get really stuck so I’ll come back after I’ve taken a break and had another go!