Hello! How can i make it works? I’m trying to do this for some humanoid attributes (sanity, stamina, something like that) to when i call this function i can just put the value to decrease ou increase and the attribute inside the parenthesis.
Code to be Reviwed:
local Increase = {}
function Increase.Increase(value: number, stat)
stat += value
print("Increased")
end
function Increase.Decrease(value: number,stat)
stat -= value
print("Decreased")
end
return Increase
Then you need to use SetAttribute and GetAttribute.
Maybe make the function to take the humanoid as an argument and then humanoid:SetAttribute(stat, humanoid:GetAttribute(stat) + value)
Thanks, i can call a variable that is not on the module script and just on the script or local script i’m calling it? cuz i dont know if is possible call the humanoid by a module script.
local API = {}
API.__index = API
function API.new(humanoid)
local self = setmetatable({
_humanoid = humanoid,
_stamina = 0,
_sanity = 0,
},API)
return self
end
function API:AddStamina(stamina)
self._stamina += stamina
end
usage for this:
local module = require(modulepath)
local new_humanoid = module.new(humanoid)
new_humanoid:AddStamina(10)