I need help for school project

Godot Version

godot-4

Question

Hi, i have to create a game for my school project and i am trying to make my player have different speed and jump height per different level but i dont know how?

extends CharacterBody2D
@onready var player: CharacterBody2D = $"."


const SPEED = 150.0
const JUMP_VELOCITY = -250.0
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D


func _physics_process(delta: float) -> void:
	
	
	# Gravitation
	if not is_on_floor():
		velocity += get_gravity() * delta

	# Springen
	if Input.is_action_just_pressed("jump") and is_on_floor():
		velocity.y = JUMP_VELOCITY


	#Richtungs eingaben
	var direction := Input.get_axis("move_left", "move_right")
	
	#Sprite drehen
	if direction > 0:
		animated_sprite.flip_h = false #Horizontal drehen
	elif direction < 0:
		animated_sprite.flip_h = true 
	
	#animationen
	if is_on_floor():
		if direction == 0:
			animated_sprite.play("Idle")
		else:
			animated_sprite.play("sprint")
	else:
		animated_sprite.play("jump")
	
	#Bewegung Hinzufuegen
	if direction:
		velocity.x = direction * SPEED
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)

	move_and_slide()

Give each level scene a script and add speed and jump height for the player. And then get the speed and height from the level.

#Player_script

@onready var level: Control = $".."

func _ready() -> void:
	print(level.speed)#get the speed
#Level script
var speed:float = 205.0

NOTE: It’s the lazy way. You can use autoloads

If you create a script that’s not attached to any node, then go into project settings, auto load, then you should be able to set that new script to an auto load.
In the auto load you add a variable:
var player

In the player, you change speed and jump height from const → var

In each level you add a script where, in the ready function, you say:

YourAutoloadName.player.jumpheight = whatever
YourAutoloadName.player.speed = whatever

Use @export variables for SPEED and JUMP_VELOCITY, you can assign them different values to the player in each level, assuming you’re using change_scene_to_file and your player does not persist between levels