I cannot Change Scenes I really need help😭

Godot Version

4.2.2.stable

Question

My scenes aren’t transitioning. I need help. I’m tired and I don’t know what I’m doing wrong. This is the first code:


extends Control

@export var next_scene = ā€œres://GameScenes/InitialStory.tscnā€
var load_progress = 0
var max_progress = 100

func _ready():
$LoadingTimer.start()

func _process(delta):
if load_progress < max_progress:
load_progress += delta * 20 # Adjust speed as needed
$LoadingBar.value = load_progress
else:
$LoadingBar.value = max_progress

func _on_LoadingTimer_timeout():
if load_progress >= max_progress:
get_tree().change_scene(next_scene)

In this code, I just want the Scene to go to the InitialStory scene after the Loading Bar reaches Max. That’s all but it’s not working and it’s just killing me.

This is second code:


extends Control

@export var tutorial_scene = ā€œres://GameScenes/Tutorial.tscnā€

func _ready():
# Connect the button’s pressed signal to the function
$NextButton.connect(ā€œpressedā€, self, ā€œ_on_NextButton_pressedā€)

func _on_NextButton_pressed():
# Load the tutorial scene
get_tree().change_scene(tutorial_scene)

This one isn’t working either :sob::sob: please help. My game needs Scene changes to fundamentally work.

Please edit your post and use the </> button to make your code display with indentation and syntax highlighting (you select a chunk of code and then press the button). This will make it much easier to see what’s going on.

In the first piece of code, I’m guessing that the part that actually calls change_scene is commented out, since it got turned into a header here, which happens for lines that start with #. If so, it might help to have that code actually running… Also, have you checked if perhaps the problem is that load_progress doesn’t become large enough?

In the second piece of code, try connecting the signal like this:

$NextButton.pressed.connect(_on_NextButtton_pressed)

^ This is the Godot 4.x syntax for connecting signals.

1 Like

try this:

get_tree().change_scene_to_file("res://path_to_the_scene/tutorial_scene.tscn")

Change ā€œpath_to_the_sceneā€ to the path in your project to the scene file.

Also, you can do a print(ā€œButton Pressed!!ā€) just in case your problem is that the signal is not connected to your procedure so the button is actually not doing anything.