My game has some skills when being activated gives you a shield for a certain time, the maximum shield per player is 3, and each shield blocks the damage of 1 skill, so I made this system, when the player uses a skill that gives shield I call this module:
local Shield = {}
local module = {}
function module.New(caract)
local Data = {
["Shield"] = 0
}
Shield[caract] = Data
end
function module.Delet(caract)
Shield[caract] = nil
end
function module.Set(caract,value)
Shield[caract]["Shield"] = value
end
function module.Get(caract)
if Shield[caract] == nil then
module.New(caract)
end
return Shield[caract]["Shield"]
end
function module.RemoveShield(caract,value,shieldTime, initialValue)
for count = 1, shieldTime, 1 do
if initialValue ~= module.Get(caract)then
break
else
if module.Get(caract) > 0 then
module.Set(caract,module.Get(caract)-value)
end
end
wait(1)
end
end
function module.Increase(caract,value, shieldTime)
if (module.Get(caract) + value) > 3 then
module.Set(caract,3)
module.RemoveShield(caract,value,shieldTime,module.Get(caract))
else
local amount = module.Get(caract) + value
module.Set(caract,amount)
module.RemoveShield(caract,value,shieldTime)
end
end
return module
So if anyone have any suggestion tell me please