• Godot Help
  • (help) problems with connecting custom signals from one scene to another

hello. I need help with connecting a signal from one scene to another. I have a character2D within its own scene that emits a custom signal called "player_entered" when another Area 2D enters its Area 2D. I want to connect this signal to 4 nodes within my main scene in order to make them do certain things like animate if the player presses a certain key (essentially interactable objects). I tried following a tutorial in order to link the signal to the script that will be attached to the 4 nodes, however, I failed multiple times trying to do this and the code I have now is returning errors. these errors are (Line 5:Invalid argument for "connect()" function: argument 2 should be "Callable" but is "res://Scripts/TerminalSystemScript.gd".), (Line 5:Cannot pass a value of type "String" as "int".), and (Line 5:Invalid argument for "connect()" function: argument 3 should be "int" but is "String".). At this point, I don't know what I did wrong or if what I'm trying to do is even possible with my current approach. here is my code.

`extends Node2D

func _ready():
get_parent().get_node("CharacterBody2D").connect("player_entered", self, "on_player_entered")

func on_player_entered():
print("it works")

`

  • xyz replied to this.

    Is that Godot 3 or Godot 4? The error sounds like Godot 4. But you are using Godot 3 code. Try this line instead:

    get_parent().get_node("CharacterBody2D").player_entered.connect(on_player_entered)

    stimpus1 Peek into Godot's documentation and check what arguments need to be passes to connect() method. Make sure that your code is passing the proper arguments.

    Also it's not a good idea to do 3.x tutorials in 4.x. People who try it get regularly stuck on stuff like you've just encountered. Why not use the exact version of Godot the tutorial is made for?