#Updating Gui when a value changes

1 messages · Page 1 of 1 (latest)

plush hornet
#

So right now I have my character stats in a simple table like this:

local stats = {
      ["hp"] = 100,
      ["stamina"] = 50,
}

Now the problem is when I take damage for example I will have to manually update the hp bar gui but I dont like how messy my code becomes since I have to deal the damage, play the sound and update the gui etc.. all at the same time so I would like to separate gui updating first but im not sure if these approaches are fine or there is another better way?

event based:

  1. Use proxy table to check when hp changes and update the gui? (maybe put gui objects inside metatable when they get created?)
  2. Maybe store the values as attributes/IntValues and just use propertychanged (This is probs a bad idea)

loop based:

  1. Just check every frame the value of hp and update the gui?
gloomy viper
#

event based