Scenes won't change and the game stops when it run it

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

I don’t get what’s happening, the code says its "Error change_scene(path: String)

  • extends KinematicBody2D

    var velocity = Vector2(0,0) const speed = 80 const gravity = 3 const
    jump_force = -80

    func _physics_process(delta): if
    Input.is_action_pressed(“ui_right”): velocity.x = speed
    $AnimatedSprite.play(“Run”) $AnimatedSprite.flip_h = false

    elif Input.is_action_pressed(“ui_left”): velocity.x = -speed
    $AnimatedSprite.play(“Run”) $AnimatedSprite.flip_h = true

    else: $AnimatedSprite.play(“Idle”) velocity.x = 0 if not
    is_on_floor(): $AnimatedSprite.play(“Jump”) velocity.y =
    velocity.y + gravity if Input.is_action_just_pressed(“ui_up”) and
    is_on_floor() || Input.is_action_just_pressed(“ui_up”) and
    is_on_wall(): velocity.y = jump_force velocity =
    move_and_slide(velocity,Vector2.UP) velocity.x =
    lerp(velocity.x,0,0.2)

    func _on_fallzone_body_entered(body):
    get_tree().change_scene(“res://Level1.tscn”)

:bust_in_silhouette: Reply From: dustin

the change scene functions needs a “scenepath”. not a string.

change the string in the change_scene() function to load("res://Level1.tscn") so its instead gonna change to a scene, and not a string

hope this fixes your problem !

Thanks for helping me. I tried your way and it still didn’t work, and i found that changing the collision layer helped tho…

Drawsi | 2020-06-23 19:38