Invalid access of index '0' on a base object of type: 'Array[BaseButton]'.

Godot Version

4.7.2

Question

I’m very new to Godot and to coding as a whole, and have been stuck on the same problem for days. Im trying to make a dialogue system, and am following a YouTube tutorial because I’m new, but I have this stupid error that I just cant fix.

Even when this is fixed, I’m sure there will be new problems, but any help would be great.

Code:

extends CanvasLayer

@export var b_group : ButtonGroup
var dia_choices : Dictionary

signal next_id(id: String)


func _ready() -> void:
	b_group.pressed.connect(get_choice)

func set_choices(choices: Dictionary):
	print(choices)
	var index = 0
	var buttons = b_group.get_buttons()
	for c in choices.keys():
		print(c)
		buttons[index].text = c
		index += 1
	pass

func get_choice(b : Button):
		print(b)
		pass

b_group seems to be an export variable, did you set it up in the inspector? If you open up that scene, you will see on the right side that the b_group variable is empty. You need to point that to your ButtonGroup.