Invalid access to property or key 'current' on a base object of type 'null instance'

Godot Version

4.6.1

Question

This error appeared after commenting out this if block:

if is_on_floor():
    health.current = health.current - velocity.length() * ground_momentum_danger
else:
    health.current = health.current - velocity.length() * air_momentum_danger

the error means you are trying to use .current on something that is null. Look for what ever is left of “.current”, for what ever reason that object is null. In your case it appears to be health.

1 Like

This seems to be the only line of code affecting health.current:

	health.current += 10

How it is defined may be the most important information, where is your var health?

@onready var health: Health = $Health

“Health” must not be a node as a child of the script, you probably also get a warning about this. What does your scene tree look like?

I renamed the node…Silly me!:sweat_smile: