I’m looking for the most efficient and proper way to consider damage taken and health changes in my game.
Currently I’m using the DataStore2 module and have a constant feed of the most updated data being sent to the client, in order to display their Stats on a GUI.
The only option that comes to my mind, is to set the data store with the most current values of the health or mana, each time its changed.
The only thing I was considering before doing this, Is what happens when a single player is being attacked by multiple enemies at once. The damage event will be called to in a quickly manner, within a short period of time. Would this overload the users data (datastore2) ?
Below is an example of how I would increase a players level when they level up.
userData[slot].CharData.Level = userData[slot].CharData.Level + 1 --Increases the level
DataStore2(userDataStoreName, player):Set(userData) --Sets & saves into datastore
An example I just came up with on how I think the health would work…
local function takeDamage(player, slot, damage)
userData[slot].CharData.currentHealth = userData[slot].CharData.currentHealth - damage
DataStore2(userDataStoreName, player):Set(userData)
end
Any ideas would help! Thanks.