I'm new to coding and making a endless runner game and coded in a jump input it works for the menu, then when the game plays my player runs then falls to his death. He could run on the platform but he isn't able to jump
here's the script
extends KinematicBody2D
const UP = Vector2(0, -1)
const GRAVITY = 5
const JUMPSPEED = 150
const JUMPHEIGHT = -350
var velocity = Vector2.ZERO
func _process(delta):
velocity.y += GRAVITY
if Input.is_action_just_pressed("Jump") and is_on_floor():
velocity.y = JUMP_SPEED
if is_on_floor():
$AnimatedSprite.play("Run")
else:
$AnimatedSprite.play("Jump")
move_and_slide(velocity,Vector2.UP)
func onfallzonebodyentered(body):
gettree().changescene("res://scenes/TitleScreen/Title Screen.tscn")
thanks in advance