Need help with my Global Signals

Hello Guys,
i´m pretty new to Godot and trying to send my Playerdmg to an enemy via an autoload script, but for some reason i´m not able to make it work. Guess if i´m able to get kind of understanding of signaling, i will help me in future on things like signaling exp on enemy kills and so on.
I´m really helpful for any advise, here are the parts of the different scripts:
Playerscript:
var playerdamage:int:
set(value):
playerdamage = value
Messenger.PLAYER_DAMAGE_CHANGED.emit(playerdamage)
print(player)

func _ready():
playerdamage = base_damage + weapon_damage + strength

Messenger Autoload:
extends Node

signal PLAYER_DAMAGE_CHANGED(new_value)

Enemy:
var playerdamage = 0

func _ready():
Messenger.connect(“Player_DAMAGE_CHANGED”, on_player_playerdamage_changed)

func on_player_playerdamage_changed(new_value):
playerdamage = str(new_value)
print(“Player damage updated to:”, playerdamage)

Try connecting the signal like this:
Messenger.PLAYER_DAMAGE_CHANGED.connect(on_player_playerdamage_changed)
Your way of connecting should work too, but it doesn’t always for some reason…

edit: oh you also typed it wrong, “Player_DAMAGE_CHANGED” should be all capital

1 Like

Thank you for the replay, i changed the letters to be all Capital in my script. Still not be able to add the damage in my enemy script. Am i supossed to connect the signal the way you suggested in my playerscript?

In the Enemy script’s ready function, replace this line with what I posted:

func _ready():
Messenger.connect(“Player_DAMAGE_CHANGED”, on_player_playerdamage_changed)

Not sure if that’s the issue, but you can try

1 Like

build in some print functions:
Playerscript:
var playerdamage:int:
set(value):
playerdamage = value
Messenger.PLAYER_DAMAGE_CHANGED.emit(playerdamage)
print(playerdamage , “transmitted”) ## Works with the correct value
Enemy:
func _ready():
Messenger.connect(“PLAYER_DAMAGE_CHANGED”, on_player_playerdamage_changed)
print (“connected to Messenger”) ## Prints

func on_player_playerdamage_changed(new_value):
playerdamage = (new_value)
print(“Player damage updated to:”, playerdamage) ## no print