My instantiate code wont work they way i want

godot 4.3

i am trying to write code that instantiate a segment of my game paddle with a offset every time the test key is pressed increase but the code isnt working despite not giving me an error code just marks line 20 as the breaking point

extends CharacterBody2D
@export var speed = 200

var health =0
@onready var segment:PackedScene= preload(“res://scene/paddlesegement.tscn”)
var segmentoffset = 0
func get_input():
var input_direction = Input.get_axis(“left”, “right”)
velocity.x = input_direction * speed
func health_increase():
health = health +1
func _physics_process(delta):
get_input()
move_and_slide()#how i control paddle movement ^
if Input.is_action_just_pressed(“test input”):
var spawnsegment = segment.instantiate()
spawnsegment.postion = Vector2(position.x+segmentoffset,position.y)

	add_child(spawnsegment)
	segmentoffset += 32
	print("spawnlinesegment")

Do you mean a ‘breakpoint’? Is there a red pip next to line number 20? If so, click it once to make it go away, then run your project again.

1 Like

thank you that gets me the error but i still dont know what im doing wrong
here the error

Invalid assignment of property or key ‘postion’ with value of type ‘Vector2’ on a base object of type ‘CharacterBody2D’.

There’s a typo in your code. This should be position.

1 Like