I’ve recently just followed the dev forum tutorial on making a data store saving script, (which I completely understand how it works) but just unsure about one part in the function.
function PlayerStatManager:ChangeStat(player, statName, value)
I know this would be the function to call to change the values, but I’m not entirely sure how I would call it using a separate script. The values currently are Money and Experience.
I know how to require a module script, I’m asking how to change a value after requiring the module script. The code after that simply just increases the value in a table.
--Module Script
local module = {}
functions module:ChangeStat(player, statName, value)
--Your code that changes the value
end
return module
--Server Script
local module = require(Path.to.module)
module:ChangeStat(player, statName, value) --Just call the method
Using : passes the table that the function was a part of as the first argument. This argument is automatically set up as self if the function is defined using a : as well. So, in that case, self would be module.