Stuck with null instance

godot 4

extends CanvasLayer

const stondo = preload("res://sample map/map/stondo.tscn")
const bacoor = preload("res://sample map/map/bacoor.tscn")

func _ready():
	get_node("TextureRect").hide()
	get_node("Label").hide()
	
func ChangeMap(stage_path):
	get_node("TextureRect").show()
	get_node("Label").show()
	get_node("anim").play("TransIn")
	await get_node("anim").animation_finished
	
	var stage = stage_path.instantiate()
	get_tree().get_root().get_child(1).free()
	get_tree().get_root().get_child(stage)
	
	get_node("anim").play("TransOut")
	await get_node("anim").animation_finished
	get_node("TextureRect").hide()

im stuck in ((attemp to call function hide in base null instance on a null instance) please help me

What line is giving you a null instance?

Let us suppose it is the first one.

	get_node("TextureRect").hide()

The error means that you said "get the direct child called ‘TextureRect’ ". But the engine looked for it and could not find it.

Check your spelling and your scene tree. If you click on the “textureRect” node in the editor scene tree, and drag it over to the editor and drop it in your code, it will drop the actual path and name to the node into your code.

Hope that helps.

PS You do not have to keep getting nodes. You can store a reference in a value like this:

@onready var TextureRect = $TextureRect

Then use it like this:

TextureRect.hide()