Copying Textures

Godot Version

4.5.1

Question

I am trying to copy the item’s texture onto a sprite2d of the inventory slot. However, when I run this code (Which from my research SHOULD work [If more code is needed I can provide it, but I’m pretty sure this is the only relevant part]), it gives me the error

E 0:00:02:246 InventorySlot._process: Invalid access to property or key ‘texture’ on a base object of type ‘null instance’.
Inven_slot.gd:26 @ InventorySlot._process()
Inven_slot.gd:26 @ _process()
Help?

$"../Inven_Slot/Item_texture".texture = $"../Item/item_base_texture".texture

Does the texture actually exist on the path?

One (or both) of your node paths is incorrect.

I thought it did;

class_name InventorySlot extends Area2D
var is_in = false
var mouse_is_in_slot = false
var dropped = false
@onready var Item_Texture = $Item_texture
@onready var IBT1 = $"../Item/item_base_texture"


#Detects when item enters
func _on_area_entered(area: Area2D) -> void:
#	is_in = true
	Global.global_is_in = true


# Detects when item exits
func _on_area_exited(area: Area2D) -> void:
#	is_in = false
	Global.global_is_in = false

#Moves the item into the slot
func _process(_body) -> void: 
	if Global.global_is_in == true:
		if !Input.is_action_pressed("Click"):
			dropped = true
			Global.global_is_in = false
			$"../Inven_Slot/Item_texture".texture = $"../Item/item_base_texture".texture
			$"../Item".visible = false
	#Script to take item out of slot
	if mouse_is_in_slot == true:
		print("Mouse works")
		if Input.is_action_pressed("Click"):
			print("Mouse + Click works")
			$"../Item".visible = true
			$Item_texture.texture = null



#Does nothing rn
func _ready() -> void:
	pass


#Detects if the mouse enters
func _on_area_mouse_entered(area: Area2D) -> void:
	mouse_is_in_slot = true


#Detects when the mouse exits
func _on_area_mouse_exited(area: Area2D) -> void:
	mouse_is_in_slot = false```

Check the spelling, sometimes “item_texture” could be “Item_texture” . Can you post a picture of the Node tree showing the scene ?

This is the inventory scene tree

Expand the branches.

What is your script attached to? Seems like it will only ever apply to the first Inven_Slot node, maybe you should be using $Item_texture if this script is attached to each Inven_Slot# node

Screenshot 2026-08-16 at 9.18.35 AM
I thought my bases were covered by this

That’s partially what I’m referring to when I say it only applies to the one item. The $"../Item/item_base_texture" will only ever apply to the first item. Though you never use IBT1 in your script so those lines really have no effect in the script, but you do again use $"../Item" paths which will only apply to the first.

If you delete or rename this “Item” node then your script will fail for every item node thereafter.