Setting values through functions VS. Setting values manually

Right now, I’m making the stats for the abilities in my game, and I can’t decide on which one is better. Should I just set them or make a function to set them? ( or is there an alternative way to set the stats for the abilities?)


--DPH IS DAMAGE PER HIT
--CD IS COOLDOWN

-- THIS MIGHT BE INCORRECT BUT ITS JUST AN EXAMPLE

module.Data = {
	create = function(table,name,event,dph,cd)
		local new = {}
		new.Event = event
		new.DPH = dph
		new.Cooldown = cd	
		table[name] = new
	end,
}

module.Data:create('Bone Shot',game.ReplicatedStorage.Abilities.bone_shot,200,4)

--OR

module.Data = {
	['Bone Shot'] = {DPH = 200,Event = game.ReplicatedStorage.Abilities} -- and so on.....
}
return module

I might be making a big deal out of this, but I really cant decide…

How I personally do data stuff is I have a function for Getting the values and Updating them
these functions listed below are located in a modulescript i made, and I am just referring to what I named them
:Get() and :Update()
:Update() is for sending data to the client and updating leaderstats
:Get() returns the data

For creating the data initially when the player joins, I use :Load()

For modifying data, I abuse the fact that tables are linked. After all the modifications, I call :Update()

1 Like