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:
- Use proxy table to check when hp changes and update the gui? (maybe put gui objects inside metatable when they get created?)
- Maybe store the values as attributes/IntValues and just use propertychanged (This is probs a bad idea)
loop based:
- Just check every frame the value of hp and update the gui?