Hello everyone,
I am new to Defold and trying to learn
How to get/change another script variable??
I have created two objects, a player and stars, with two scripts:
player.script and stars.script.
player.script
local score = 0
stars.script
function on_message(self, message_id, message, sender)
if message_id == hash("collision_response") then
local hero_score = go.get_id("hero").score
hero_score = hero_score + 10
go.delete()
end
end
but not work for me
ERROR:SCRIPT: stars/stars.script:6: attempt to index a userdata value
stack traceback:
stars/stars.script:6: in function <stars/stars.script:5>
I have tried different combinations, but none of them worked.
local hero_score = go.get_id(“hero”,“score” )
local hero_score = go.get_id("#hero )
local hero_score = go.get_id("/hero )
go.set(“hero”, “score”, +10)
What am I doing wrong? Thank you very much.