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!

    pixelmoon How is _heal() being called?

    Btw put your code between lines containing ~~~ to format it properly.

    pixelmoon
    @export var char_stats: CharacterStats
    is this being set up from code or in the editor?
    if you set it up from code, remove export. exports are shared between copies of the same instance, so if you change one it can change other scenes in the game.
    if you set it up from the editor, you forgot to select the object in the export.

    it could also be that the node you setup is not of class CharacterStats. are you setting this name in the script with:
    class_name CharacterStats

    and does the node have the script attached?