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

Godot Version

4.3

Question

drag/dropping from scene tree to code is returning a null value, I tried with $TextureRect as well and it did the same thing, can someone help me understand what I need to do to get this to work? here’s my script.

image

and here’s the scene tree

image

EDIT: I Just figured it out, I haven’t seen this solution presented before, so I’m going to post this anyway in case someone has the same issue:

The “inventory.tscn” scene was in “res://” and not in “res://Scenes” like the rest, I have some guesses why this affects stuff, but placing the inventory scene with the rest of my scenes fixed the issue