Invalid access to property or key '4' on a base object of type 'Dictionary'

Godot Version

4.6.3

Question

Hey New to Godot and have been following this tutorial on Youtube:

I got to the point of trying to test the code, but it is coming back with a error saying this " get_data_vaule: Invalid access to property or key ‘4’ on a base object of type ‘Dictionary’." I looked at the code on the Main Data Manager -Line 21- and the code seems fine, but I noticed it seems to through up errors dealing with the selection. And Key 4 seems to be The “OBJ_SELECTED,” in the Data Const. Been trying to figure it out but is very confusing. Here is my full error:

  E 0:00:00:796   get_data_vaule: Invalid access to property or key ‘4’ on a base object of type ‘Dictionary’.main_data_manager.gd:21 @ get_data_vaule() main_data_manager.gd:21 @ get_data_vaule()       
action_selectable.gd:38 @ _set_obj_selected_to()
action_selectable.gd:30 @ deselect_obj()
 action_selectable.gd:27 @ initialize_action()
  main_actions_manager.gd:24 @ initialize_actions()
  base_unit.gd:42 @ _startup()
    base_unit.gd:27 @ _ready()"

Here are the Code in the Files:

Main Data Manager:

#meta-space-indent: 4
extends RefCounted
## enums
## consts
const SCRIPT_OBJDATA_CONTS: = preload("res://Data/World/Objects/Comps/Data/data_consts.gd")
## exports
## public vars
## private vars
## onready vars
	# Obj_ for Node Refs
## built-in override methods
## public methods
static func debug_data_dict(obj_caller:Node) -> void:
	print("\n>>DEBUG_PRINT: 'obj_data' from Node'",obj_caller.name,"'")
	var obj_data:Dictionary = get_data_dict(obj_caller)
	for data in obj_data.keys():
		#
		print(SCRIPT_OBJDATA_CONTS.DATA_ENUMS.keys()[data], " : ", obj_data[data]," TYPE> ",
		Globals.get_vartype_string_from_var(obj_data[data]))
static  func get_data_dict(from_object:Node) -> Dictionary:return from_object.obj_data
static func get_data_value(from_object:Node,key:int) -> Variant:return from_object.obj_data[key]
static func has_data_key(from_object:Node,key:int) -> bool:return (from_object.obj_data as Dictionary).has(key)
static func set_data_vaule(from_object:Node,data_key:int,new_data_value:Variant) -> void:
	# Ensure type safety before changing it.
	if  has_data_key(from_object,data_key):#(from_object.obj_data as Dictionary).has(data_key)
		var current_var:Variant = from_object.obj_data[data_key]
		if typeof(current_var) != typeof(new_data_value):
			push_error(
				"\n>>Type mismatch:For set_data_vaule()! For object: ", from_object.name,
				"\n>>Expected'",Globals.get_vartype_string_from_var(current_var),"'but got'",
				Globals.get_vartype_string_from_var(new_data_value),"'.'",
				"\n<--->Key Enum Int: ",data_key,
				"\n<--->Old_Var:",from_object.obj_data[data_key],
				"\n<--->New_Var:",new_data_value,
			)
			return # Unexpected change in type
			
	# Set Data for Object
static func add_data_vaule(from_object:Node, data_key:int, new_data_vaule:Variant) -> void:
	#Adds vaule to a data as Array. check for dupicate.
	if has_data_key(from_object,data_key): #if (from_object.obj_data as Dictionary).has(data_key)
		var expected_array: Variant = get_data_value(from_object,data_key)
		if expected_array is Array:
			if (expected_array as Array).find(new_data_vaule):return #Data Already present.
			else: (from_object.obj_data[data_key] as Array).append(new_data_vaule) # Apppends new vaule
	set_data_vaule(from_object,data_key,new_data_vaule) #What if we want an array instead?

## private methods

Main Action Manager:

#meta-space-indent: 4
extends RefCounted
# Manages and stores actions

## enums


## consts
const  SCRIPT_ACTS_CONST: = preload("res://Data/World/Objects/Comps/Actions/actions_conts.gd")
const ACTION_SCRIPT:Dictionary[int,Script] = {
	SCRIPT_ACTS_CONST.ACTION_NAMES.ACTION_MOVE : preload("res://Data/World/Objects/Comps/Actions/action_move.gd"),
	SCRIPT_ACTS_CONST.ACTION_NAMES.ACTION_SELECTABLE : preload("res://Data/World/Objects/Comps/Actions/action_selectable.gd")
	}
## exports
## public vars
## private vars
## onready vars
	# Obj_ for Node Refs
## built-in override methods

## public methods
static func initialize_actions(obj_caller:Node,actions:Array[Script]) -> void:
	for action:Script in actions:
		action.initialize_action(obj_caller)

## private methods

Data Const :

#meta-space-indent: 4
extends RefCounted
## enums
enum DATA_ENUMS{
	#OBJDATA
	
	OBJ_PATH,
	OBJ_CURRENT_PATH_INDEX,
	OBJ_PATH_GOAL,
	OBJ_SELECTED,
	OBJ_SELECTED_SPRITE,
	
	MOVE_SPEED,
}
## consts
## exports
## public vars
## private vars
## onready vars
	# Obj_ for Node Refs
## built-in override methods
## public methods
## private methods

Action Selectable:

#meta-space-indent: 4
extends RefCounted
## enums
## consts
const SCRIPT_DATA_MANAGER:= preload("res://Data/World/Objects/Comps/Data/main_data_manager.gd")
const SCRIPT_DATA_CONSTS:= preload("res://Data/World/Objects/Comps/Data/data_consts.gd")
const SPRITE_3D_CIRCLE_SELECTION: = preload("res://Data/Core/Templates/SelectionManager/SMComps/spite3d_selection_decal.tscn")
#ALIASES
const __DATA_CONSTS = SCRIPT_DATA_CONSTS.DATA_ENUMS
## exports
## public vars
## private vars
## onready vars
	# Obj_ for Node Refs
## built-in override methods

# Called when the node enters the scene tree for the first time.

## public methods
static func initialize_action(caller:Node3D) -> void:
	SCRIPT_DATA_MANAGER.set_data_vaule(caller,__DATA_CONSTS.OBJ_SELECTED,false)
	var sprite_copy: =SPRITE_3D_CIRCLE_SELECTION.instantiate()
	caller.add_child(sprite_copy)
	sprite_copy.global_position = caller.global_position + Vector3(0,0.05,0)
	SCRIPT_DATA_MANAGER.set_data_vaule(
		caller,__DATA_CONSTS.OBJ_SELECTED_SPRITE,sprite_copy)
	deselect_obj(caller)

static func select_obj(obj_caller:Node3D) -> void:_set_obj_selected_to(obj_caller,true)
static func deselect_obj(obj_caller:Node3D) -> void:_set_obj_selected_to(obj_caller,false)
static func toggle_select_obj(obj_caller:Node3D) -> void:
	_set_obj_selected_to(obj_caller,
	!SCRIPT_DATA_MANAGER.get_data_value(obj_caller,__DATA_CONSTS.OBJ_SELECTED)
	)
## private methods
static func _set_obj_selected_to(obj:Node3D, set_selected_to:bool) -> void:
	SCRIPT_DATA_MANAGER.set_data_vaule(obj, __DATA_CONSTS.OBJ_SELECTED,set_selected_to)
	var object_selection_sprite:Sprite3D = (SCRIPT_DATA_MANAGER.get_data_value(obj,__DATA_CONSTS.OBJ_SELECTED_SPRITE) as Sprite3D)
	object_selection_sprite.visible = set_selected_to

Base Unit:

#meta-space-indent: 4
extends MeshInstance3D
## enums
## consts
const  SCRIPT_ACTS_MANAGER:= preload("res://Data/World/Objects/Comps/Actions/main_actions_manager.gd")
const  SCRIPT_ACTS_CONSTS:= preload("res://Data/World/Objects/Comps/Actions/actions_conts.gd")
const SCRIPT_DATA_MANAGER:= preload("res://Data/World/Objects/Comps/Data/main_data_manager.gd")
const SCRIPT_DATA_CONSTS:= preload("res://Data/World/Objects/Comps/Data/data_consts.gd")
const OBJ_ACTIONS:Array[Script]= [
	__ACTS_SCRIPTS[__ACTS_CONSTS.ACTION_MOVE],
	__ACTS_SCRIPTS[__ACTS_CONSTS.ACTION_SELECTABLE],
]
#Aliases
const __ACTS_CONSTS:= SCRIPT_ACTS_CONSTS.ACTION_NAMES
const __ACTS_SCRIPTS:= SCRIPT_ACTS_MANAGER.ACTION_SCRIPT
const __DATA_ENUMS:= SCRIPT_DATA_CONSTS.DATA_ENUMS

## exports
## public vars
var obj_data:Dictionary ={}
## private vars
## onready vars
## built-in override methods

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	_startup()


func _physics_process(delta: float) -> void:OBJ_ACTIONS[0].call_on_physics_tick(self,delta)


## public methods
func new_path(where_to:Vector3) -> void:__ACTS_SCRIPTS[__ACTS_CONSTS.ACTION_MOVE].path_new(self,where_to)
func select_obj()-> void:OBJ_ACTIONS[1].select_obj(self)
func deselect_obj()-> void:OBJ_ACTIONS[1].deselect_obj(self)
func toggle_select_obj()-> void:OBJ_ACTIONS[1].toggle_select_obj(self)

## private methods
func _startup() -> void:
	SCRIPT_DATA_MANAGER.set_data_vaule(self,__DATA_ENUMS.MOVE_SPEED,12.0)
	SCRIPT_ACTS_MANAGER.initialize_actions(self,OBJ_ACTIONS)

	#obj_selection_aabb.show()
	#obj_selection_aabb.mesh = BoxMesh.new()
	#var selection_aabb:AABB = global_transform * mesh.get_aabb()
	#var aabb_center: Vector3 = selection_aabb.position + selection_aabb.size * 0.5
	#obj_selection_aabb.mesh.size = selection_aabb.size
	#obj_selection_aabb.position = aabb_center
	#obj_selection_aabb.queue_free()

Thank you for checking this out Thank you