I want to make my character to teleport to his spawnpoint?

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

I have been watched some other discussion about this and tried some things but i haven’t found the solution. I try to make the character to goto his spawnpoint after he got died.

but always came this
Invalid set index ‘position’ (on base: ‘PackedScene’) with value of type ‘Vector2’.

my code:

extends KinematicBody2D
export (PackedScene) var body

export var health = 6
var dash_timer = 200

signal dead
signal damage_taken

export var speed = 180
export var jump_force = 400

const UP = Vector2(0, -1)
var velocity = Vector2()

func _ready():
$CollisionShape2D.disabled = false

func _process(delta):
dash_timer -= 1

if Input.is_action_pressed("d"):
	velocity.x = speed
elif Input.is_action_pressed("a"):
	velocity.x = -speed
	$Sprite.animation = "Idle"
	velocity.x = 0

if is_on_floor():
	velocity.y = 0
	if Input.is_action_pressed("space"):
		velocity.y = -jump_force
velocity = move_and_slide(velocity, UP)

if !is_on_floor():
	velocity.y += 10
	if Input.is_action_pressed("s") && dash_timer < 10:
		dash_timer = 200
		velocity.y += 400

func _on_Area2D_body_entered(body):
health -= 1
speed += 20

func _on_HUD_dead1():
$CollisionShape2D.disabled = true
body.position = Vector2(64, 448)
$CollisionShape2D.disabled = false

:bust_in_silhouette: Reply From: andersmmg

The body variable doesn’t seem to ever be set? It’s only initialized. Also, it this script is running from the node you want to move, you can just use position=Vector2() without referencing anything.