I am confused about the errors i am getting

Godot Version

Godot 4.2.1

So this is my code:
extends Node

onready var sprite2D = preload(“res://sprite_2d.tscn”)
func _ready():
for i in range(10):
var s = Sprite2D.instance()
add_child(s)

Basically im trying to make multiple sprites spawn and bounce around the screen ( i already made another code to do it with the main sprite ). However i keep getting the two erors: Unexpected “Identifier” in class body. and Expected indented block after “for” block.
Im really confsued about these errors and when i try to play the scene only the 1 sprite spawns and not 10.

If there is any other information you need to know to find the solution to this situation please let me know!

  • Have you tried to replace Sprite2D.instance() by sprite2D.instance()?
  • onready => @onready
  • the line after for needs to be intended by an additional TAB.
@onready var sprite2D = preload("res://sprite_2d.tscn")
func _ready():
	for i in range(10):
		var s = sprite2D.instance()
		add_child(s)

Thank you for responding, the errors have been removed but the purpose of what i am trying to achive hasnt been fixed. im trying to make it so that when the sprite bounces of the wall then another sprite spawns and starts spinning and copying the same aspect

if there is a solution to that, please let me know.