Hey guys, I’m having trouble with some GUI stuff currently I have a text node that has a text value of 0 but I want it to display the property health of my player object but for the life of me, I cant figure of out why I just get the error
bad argument #4 to ‘get’ (GOScriptInstance expected, got userdata)
function update(self, dt)
local health = go.get("main:/Player/controller#script", "health")
gui.set_text(playerHealth, 1000)
end
“argument #4” is an implicit argument that’s used in game object scripts to work properly with go.get(). From a GUI script, you won’t be able to directly use go.get(); I suggest using message passing or global variables to share information between your player and the GUI script.
Every component (be it a sprite, script, gui_script or anything else) you add to a game object will get it’s own unique URL that can be used to pass messages to the component using msg.post(). The manual on message passing should describe this in detail. but if there is anything that is unclear then please ask here and we’ll try to explain.