How do I make my player teleport into a new scene(Level) - 2D Top-Down Game

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

I’m trying to make a 2D top-down game. I’ve tried to figure out a way to have my player “teleport” to a new scene but I simply can not figure out how to do it. How would I best do this?

My Player code:

extends KinematicBody2D

export var MOTION_SPEED = 140

var Level = 1
var RayNode

func _ready():
set_physics_process(true)

RayNode = get_node("RayCast2D")

func _physics_process(delta):
var motion = Vector2()
MOTION_SPEED = 140

#Input+Motion
if (Input.is_action_pressed("ui_up")):
	motion += Vector2(0,-1)
	RayNode.set_rotation_degrees(180)

if (Input.is_action_pressed("ui_down")):
	motion += Vector2(0,1)
	RayNode.set_rotation_degrees(0)

if (Input.is_action_pressed("ui_left")):
	motion += Vector2(-1,0)
	RayNode.set_rotation_degrees(-90)

if (Input.is_action_pressed("ui_right")):
	motion += Vector2(1,0)
	RayNode.set_rotation_degrees(90)

#Sprint
if (Input.is_action_pressed("ui_Sprint")):
	MOTION_SPEED = 200

#Apply Motion
motion = motion.normalized()*MOTION_SPEED*delta
move_and_collide(motion)
:bust_in_silhouette: Reply From: 1234ab

So if you change to a new scene, the player node will also be replaced.
Make the player its own scene (if it’s not already).
Instance the player to every scene.
Then from script you can simply use
get_tree().change_scene("res://path/scene.tscn")