Discord
Login
Community
DARK THEME

Level 3 - Advanced Techniques - Button

the variable "score" didn't change the value when I clicked the two buttons.

It seemed that the button score has its own score variable.

From what you say, I am guessing you are trying to set a global variable from an object method (function). Probably something like this:

button = object
  clicked = function()
    score += 1
  end
end

If you call button.clicked() it will set a property score to your button. If you want to address the global variable instead from your object method, you can do:

button = object
  clicked = function()
    global.score += 1
  end
end

Thank you, I really need to read more documents.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community