Topic was automatically imported from the old Question2Answer platform.
Asked By
RBbooms
Hi godot-ers, thanks for clicking. I am new to the engine coming from Roblox Lua coding, and a thing you can do in there is send a signal with a variable (i.e if a drop-down with a selected value, you could send a signal with that value attached to be received by the other scripts). Is there a way to do this type of thing in Godot with emit_signal()? Like I mentioned I am extremely new to the editor and would like to get help. For reference I am making a stamina bar where the player node has the script for the stamina value, I want to send that value to another script in a canvas layer to change the value of a progress bar onscreen.
Thanks so much for the help, I’ll be checking back every day and likely asking questions to the posters.
If signals haven’t changed from Godot 3 to Godot 4, then it’s as simple as emit_signal("your_signal_name",arg1,arg2), where arg1, and arg2 are example variable that you are providing with the signal. For example, emit_signal("signal_name",52,"cat") would send 52 and "cat" to any function that is connected to "signal_name".
You can connect a function to the signal as follows: