Hello! I am super new to Godot (and development as a whole, honestly) and my game is a restaurant management game. My goal now is to be able to press a button from a menu and spawn a server NPC. Currently I have a “game” scene, where everything comes together, and then I have a “hireMenuS” scene as a child of the “game” scene. Here is the code I have so far (in GDscript):
Inside hireMenuS script
var loadServer = preload(“res://Scenes/server.tscn”)
signal hireServer
Inside game script
var preloadServer = preload(“res://Scenes/server.tscn”)
func _on_hire_menu_s_hire_server():
var serverInstance = preloadServer.instantiate()
add_child(serverInstance)
print(“server added”)
The problem is that the _on_hire_menu_s_hire_server() function does not seem to run. The print statement inside the hireMenuS script does work, but the one inside the game script never does. Is there some issue with the signal? Any help is appreciated. Also, if there is a better way to spawn the server, please let me know!
Thank you
Yes, it does show that. I just double checked, the signal should be properly connected, so I am still not sure what’s wrong! Is there maybe a different, easier way to do this? Or is there some other error?
i dont know if you have reference to your hireMenuScript’s node or not, what’s its name, so i just use hireMenuNode. Assuming you have reference to HireMenuScript attached node
Thank you. I tried adding that line but it threw an error because it was already connected, and it still doesn’t seem to run the function. I appreciate your help though
if my guess is correct, dont name your signal with PascalCase, do it with snake_case
if above is not the case, try direcly emit the signal by:
hireServer.emit()
based on the _ready() function trying to connect the signal by code, it said it’s already connected, so the signal does indeed connected, but emit doesnt get emitted, hence never triggered the _on_hire_menu_s_hire_server function
I changed both things as you suggested, but for some reason it is still not working, nor is it printing the “server added” statement. I’m really not sure at this point why nothing is happening!