Buttons dont respond after changing scenes

I have a main menu with 3 buttons (Play, Settings and Quit Game) in my mobile game, when I press Play it switches to the main scene (level 1), however when I quit to the main menu, all buttons break

Godot Version

4.2.1

I never experienced this, but i can give you an example of code for switching scenes which i use in my game:

You can have a signal like this one in your main menu:

func _on_settings_pressed():
	get_tree().change_scene_to_file("res://Scenes/settings.tscn")

And to go back:

func _on_back_pressed():
	get_tree().change_scene_to_file("res://Scenes/main_menu.tscn")

More info about this: Change scenes manually — Godot Engine (stable) documentation in English

1 Like

it’s the same code i used, but after pressing play and then going back to the main menu, the buttons on that menu stop working

Are you pausing the game with get_tree().paused = true? You’ll need to unpause it or change the Node.process_mode

Are you pausing the game with Engine.time_scale = 0.0? Then, don’t do that. Use the get_tree().paused = true method.

More info here Pausing games and process mode — Godot Engine (stable) documentation in English

1 Like

im using get_tree().paused = true

still doesn’t work

can you show me an example? im new to godot

Try get_tree().paused = false

my code for pausing is

extends Control

func _pause():
get_tree().paused = true

func _resume():
get_tree().paused = false

func Esc():
if Input.is_action_just_pressed(“pause_game”) and !get_tree().paused:
pause()
elif Input.is_action_just_pressed(“pause_game”) and get_tree().paused:
resume()

func _on_resume_button_pressed():
resume()

func _on_main_menu_button_pressed():
get_tree().change_scene_to_file(“res://UI/Main Menu/main_menu.tscn”)

func _process(_delta):
Esc()

Try adding this:

func _on_main_menu_button_pressed():
   get_tree().paused = false //add this line
   get_tree().change_scene_to_file(“res://UI/Main Menu/main_menu.tscn”)
1 Like

thanks, it worked!