Help with Winning/Losing function

Godot 4.2.2

I made a path follow 2d for a Racing game And what I want is when the “Bot” finishes the lap first than the Player that it shows a You Lose screen, But if the player wins it shows a You win Screen. Can anyone help? (I don’t have code for it)

You can tell a path follow 2D has finished it’s course when it’s progress_ratio is greater than or equal to 1, make sure to turn looping off.

extends PathFollow2D

var speed: float = 100
signal finished_path

func _process(delta: float) -> void:
    # progress is pixel-based, how far they traveled in pixels
    progress += speed * delta

    # progress_ratio is normalized, 0 is the start, 1 is the end. like 100% done
    if progress_ratio >= 1.0:
        finished_path.emit()
        set_process(false) # stops moving and emitting

Then how do I make it display a scene when it detects it has finished

Instantiate the scene and add it as a child of get_tree().root or a canvas layer.