I’m trying to send a message to a GUI script from an enemy object with this code:
-- enemydamage.script
function on_message(self, message_id, message, sender)
if message_id == cursor.PRESSED then
print("Clicked!")
msg.post("/gui#healthbars", "enemydamage", {
currentHealth = 10,
maxHealth = 100
})
end
end
I receive that message here:
-- healthbars.gui_script
function on_message(self, message_id, message, sender)
print("Received message!")
if message_id == hash("enemydamage") then
print(#message)
end
end
I get “Clicked!” and “Received message!” in the console, but also get 0 from the message table’s length. Attempting to get one of the values from that table also returns nil.
What am I doing wrong here?