Setting visablity of a sprite

Godot Version

unc dice_Result(dice_Num1, dice_Num2):
%dice_Visibility/pos1_D6.hide()
var dice_Num = dice_Num1 + dice_Num2
print("1st die "+str(dice_Num1))
print("2nd die "+str(dice_Num2))
print("total "+str(dice_Num))
dice_result1.emit(dice_Num1)
dice_result2.emit(dice_Num2)

Question

I’m trying to have dice that show the value of the rolled number 1-6 for both die are stacked on top of each other. I want all but the rolled number to disapear but am struggling with the hide/visibility functions.

What is that exactly what does the scene look like? (The structure / nodes)

A clean solution would probably be to hide everything in a loop except what you want to show.

node named dice_Visibility
sprite named pos1_D1
sprite named pos2_D1
repeat for every other number to 6

Here is perhaps one of several possible solutions.

screenshot

gdscript
extends Node2D

@onready var dice_pos: Array[Sprite2D] = [
	$Icon1,
	$Icon2,
	$Icon3,
	$Icon4,
	$Icon5,
	$Icon6
]

func show_pos(pos):
	
	for i in range(6):
		print("i: ", i)
		if i + 1 == pos:
			dice_pos[i].show()
			print("show")
		else:
			dice_pos[i].hide()
			print("hide")


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	print("dice_pos: ", dice_pos)
	show_pos(4)
	
	pass # Replace with function body.

In ‘gdscript’ you would have to adjust array data type “Sprite2D” if it is not Sprite2D and the node names. ( → %dice_Visibility/pos1_D6)