Button Pressed Changing Scene Not working

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By leodev

I am trying to make a menu and when I try to make a button press thing it been done error.

Error:

E 0:00:01.547   emit_signal: Error calling method from signal 'pressed': 
'Control(start.gd)::_change_scene()': Method not found..
 <C++ Source>  core/object.cpp:1228 @ emit_signal()

Code:

extends Control

func _ready():
  $Menu/Start.connect("pressed", self, "_change_scene", ["res://Game.tscn"])

func _change_scene():
  get_tree().change_scene("res://Game.tscn")

I don’t really know what the problem is. Maybe remove the fourth parameter from the connect() function (the string path which leads to the scene)?

Ertain | 2020-06-15 01:47

:bust_in_silhouette: Reply From: njamster

Your change_scene-method expects no arguments, but in your connect-call you provide one nonetheless: ["res://Game.tscn"]. You have to make sure, that both expect the same amount of arguments.

For me (using Godot 3.2.1stable under Linux) the error looks like this:

emit_signal: Error calling method from signal 'pressed': 'Control(start.gd)::_change_scene': Method expected 0 arguments, but called with 1..

Maybe you’re using an older version where the error message is less verbose?