Out of bounds get index '1' (on base: 'Dictionary')

Godot Version: 4.3

I’ve been hours with this.

So I’m working on a card game where I’m trying to switch from states (base, clicked, dragging…). I’m trying to create a Card State Machine, but I don’t know why it drops this error (Out of bounds get index ‘1’ (on base: ‘Dictionary’). I’ve searched for help online but nothing seems to work for me. If someone knows what am I doing wrong I would be very grateful.

Script: class_name CardStateMachineextends Node@export var initial_state: CardStat - Pastebin.com

Note: the line crashing is var new_state : CardState = states[to]

Aren’t you mixing up your dictionary’s contents?
In some places you’re putting CardState inside, and at others your putting CardState.State.
Then you’re getting an error when trying to reference a non existing key.

CardState is a subclass of Node, State is an enum.

For example in the _on_transition_requested(from: CardState, to: CardState.State) function, from would be the card that requires a State change, and to would be the State aimed.