Invalid get index 'body_spriteSheet' (on base 'GDScript') on line 22

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Korbie

Im making a script on the player so you can change hats (im following a tutorial), I checked the vid and I didnt do anything wrong. I had already made some movement scripts, but I dont think that is the problem. I even auto loaded the CompositeSprites.gd but still got the error. here is the script: p.s: Im really new and bad at GDScript

extends KinematicBody2D

var moveSpeed = 300
var dashSpeed = 800
var grav = 1000
var motion = Vector2.ZERO
var crosshairCursor = load(“res://Assets/Crosshair.png”)
var Cursor = load(“res://Assets/Cursor.png”)
var is_grounded

export var jumpSpeed = -450

const slopeStop = 64
const CompositeSprites = preload(“res://Assets/Hats/CompositeSprites.gd”)

onready var playerSprite = $Hats/Body
onready var playerColl = $CollisionShape2D
onready var raycasts = $RayCasts
onready var hatSprites = $Hats/Hats

func _ready():
playerSprite.texture = CompositeSprites.body_spriteSheet[0]
hatSprites.texture = CompositeSprites.hats_spriteSheet[0]
Input.set_custom_mouse_cursor(crosshairCursor)

func get_input():
if is_on_floor():
var moveDirection = -int(Input.is_action_pressed(“left”)) +int(Input.is_action_pressed(“right”))
motion.x = lerp(motion.x, moveSpeed * moveDirection, 0.2)
if moveDirection != 0:
$Hats/Body.scale.x = moveDirection
$Hats/Hats.scale.x = moveDirection

func _check_is_on_ground():
for raycast in raycasts.get_children():
if raycast.is_colliding():
return true

return false

func get_h_weight():
return 0.2 if is_on_floor() else 0.1

func _physics_process(delta: float) → void:
get_input()
motion.y += grav * delta
motion = move_and_slide(motion, Vector2.UP, slopeStop)

func _input(event: InputEvent) → void:
if Input.is_action_pressed(“jump”) && is_on_floor():
if is_on_floor():
motion.y += jumpSpeed

and this is the script for the CompositeSprites:

extends Node

var body_spriteSheet = {
0 : preload(“res://Assets/Hats/orange character.png”)
}

var hats_spriteSheet = {
0 : preload(“res://Assets/Hats/BasicHat.png”),
1 : preload(“res://Assets/Hats/KnightHelmet.png”)
}