Hello! I made a configurable module that saves your data, has session locking and auto-saving system.
There are some things that I would like to point out,
Module ID has been changed due to me being unable to update the old model.
In the last version (v.3.0.1), session lock has been tested with numbers. Changing someones currency then they rejoin so fast (about 2-3 seconds), module waits until old data has been saved, if it is not then module will not load data until old data gets saved or 30 minutes passes.
Module will automatically fill data if it doesn’t exists. For example if you only had “Money” on your default values and you add more onto it, for example Experience, module will automatically add Experience to the data and put it is default value.
Editing players variables will automatically update table. However editing table will not change variables value.
When getting and updating player data and auto-saving, module will wait until there is enough budget to prevent Data Stores from filling the queue, however module will not wait in BindToClose function and will try to save data as much fast as possible because Roblox gives servers 30 seconds until they really shutdown.
This module is still work in progress, bugs may occur. If you encounter any bugs or errors please let me know. This is not the final result and everything is up to change.
LuckyDataStore v3.0.0 is here with Session Locking!
local LuckyDataStore = require(7239753643)
local default = {
Money = 100,
Experience = 0,
Rank = "None",
Tools = {}, -- Tables should not be used on the combine function as they are not a variable.
}
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder")
folder.Name = "leaderstats"
local money = Instance.new("IntValue",folder)
money.Name = "Money"
local experience = Instance.new("IntValue",folder)
experience.Name = "Experience"
local rank = Instance.new("StringValue",folder)
rank.Name = "Rank"
local playerData = LuckyDataStore.CreateData(player,"Test",default)
playerData:Combine(money,experience,rank)
folder.Parent = player
end)
Module will save when player leaves and when auto-save happens, script is meant to be basic to use for everyone!
Please let me know if there is any issue with the source code or if you have any suggestions.
This is a really amazing module! Since you can save your data SO SO easily!
But still I’ve a question. How do you use the
GetDefault(value, 0 -- [[ What is this number?]])
GetData(value, value, value -- [[ What are these values?]])
local Key1 = DataStoreModule.Key == "Key1"
local Key2 = DataStoreModule.Key == "Key2"
--[[
Can we do this?
]]
These are my normal questions. Will be really appreciated if you could answer these! Thanks!
GetDefault is a function that you send the variable and its default value.
local money = Instance.new("IntValue",folder)
money.Name = "Money"
DataStoreModule:GetDefault(money,100)
In here, money is the variable that we just created and it will be 100 for default when a new player joins.
DataStoreModule:GetData(player,money,experience)
GetData is also another function and you need to put player instance first and then all your variables that you want to be saved. Which are money and experience here.
I still didn’t added a support for more keys but I will in the future as this module is still basic.
Again, thanks for your reply and if you have more questions, feel free to ask!
You have to define a value in there because you may need to use bool values as their value is true/false and string values which their value can be anything.
Yes, I added game:BindToClose function to the module because i want to make the script easier.
Why should we use this over ProfileService or Datastore2, which is easier to use, more advanced, less data loss, etc. Auto-saving systems are always a problem. You should NEVER Use them, as they are prone to data loss, and it’s just lazy.
This is a “basic” module as in the name of the post, this is just done for beginners as using data stores are not that easy for them. They may exceed the limits of data store or can’t save data etc. This is made to help those people and you are able to disable auto-save if you don’t want it, also I’m not forcing anyone to use this so if you don’t want to use it then don’t.
Yes, but this module has a lot of edge cases and doesn’t do much to protect against data loss except for some few basic features which are incredibly easy to implement. As far as easy ness to use goes, DataStore2 is far easier to use for beginners and is much better than this as it at least protects against some sort of data loss, this doesn’t do to protect against against such data loss and is overall completely useless.
You are essentially trying to trap beginners over using this module which is bad and useless, when they can simply use a much better one.
This module has a lot of flaws from looking at the source code, doesn’t even utilise BindToClose properly and saving calls will almost be dropped when server shuts down. I highly discourage anyone from using this module.
I know that it is still not that much good and I’m still working on it. It is still “basic” but while I work on it I will make more protection about data loss and hopefully backups to revert when something bad occurs.
Why I would want to “trap” players? I said I’m still developing it and I know it is not the best.
If it’s basic, why make it as a community resource in the first place? Anyone can implement a very basic data store easily just like this, and there are a lot of resources over data stores.
[quote]This module has a lot of flaws from looking at the source code, doesn’t even utilise BindToClose properly and saving calls will almost be dropped when server shuts down. I highly discourage anyone from using this module.
Instead of saying this, why don’t you help me improve it? Your just trying to make the module look bad.
I said on the post that if there is any issue or suggestions, let me know.
This module isn’t as good as other modules for example DataStore2 or ProfileService, yes I agree with that. But it just shows that it’s “Basic” meaning it probably has bugs, glitches and more. Since beginners to DataStore cannot just yet learn about DataStore2 or ProfileService since they are a little bit more difficult to understand, I’ll say this module would be really good for them!