Buttons doesn't do the function when clicked on a child of a class

Godot Version

Godot 4.7 linux

Question

I’m working on a very basic playing card game as my first project on Godot. Clicking on a card(or specifically the button attached to it) is meant to do an effect based off of the suite and rank, so I made a class named Card, and exported the rank, suite, sprite, and the button. Here is the code for the class


class_name Card

enum Suite {HEARTS, DIAMONDS, SPADES}
@export var suite := Suite.HEARTS
@export var rank := 2
@export var sprite_2d: Sprite2D
@export var button: Button

@onready var button_1: Button = $Button

func _on_button_pressed() -> void:
    if suite == Suite.HEARTS:
        ##test
        Global.debug_message = "Hearts " + str(rank)
    elif suite == Suite.DIAMONDS:
        ##test
        Global.debug_message = "Diamonds " + str(rank)
    else:
        ##test
        Global.debug_message = "Spades " + str(rank)```

The node that I used as the base class works as intended when changing its rank and suite, but trying to make a new node using that class, and copying the sprite and button nodes as-is, and assigning everything correctly, the new card doesn’t work. The button is clickable, but it doesn’t do the function

Did you connect the button’s signal to this function? Do you get any warnings/errors?

They share the same script, last time I tried connecting the button to a new script it game an edit because the button name was the same as the parent’s

Nodes can have the same script while missing a connected signal, if that signal was connected through the editor. What does your scene tree look like? Maybe it would be better to connect the signal in code?

This is what it looks like, and the signal is connected here, but the connection signal doesn’t appear on the child’s button

Then you may have to connect the signal from the other button too. Or you could disconnect this signal and apply it through code, which will always be consistent among shared scripts

@onready var button_1: Button = $Button

func _ready() -> void:
    button_1.pressed.connect(_on_button_pressed)

That worked! A million thanks, mate