Broblem with level connection

Godot Version

4.5.1

Question

Hi,when I was connecting my levels so the player could go to the next level after finishing current using finish menu I ended up with a pretty werd solution I guess,that would get a current level as a child of the root,free it,and then add as the child to the root next level,and it was working fine as intended until I tried to play the game in the web,there not a single detail was working at all.
var levels:Array[PackedScene]=[load(“res://levels/level_1.tscn”),load(“res://levels/level_2.tscn”),load(“res://levels/level_3.tscn”),load(“res://levels/level_4.tscn”)]
func _on_next_button_pressed() → void:
get_tree().paused=false
get_tree().root.get_child(1).call_deferred(“free”)
get_tree().root.add_child(levels[GameRules.level_count].instantiate())

You totally need to provide more information. If you are going to post a topic at all why dropping it halfway. What exactly doesn’t work and in what way? What debugging attempts have you made and have you found anything? Have you read the relevant documentation?