Ez-Data v1 Module

Ez-Data.
Easily save & load player data, create data objects fast and easy!

Model.

Features.

  • Save Players Data
  • Load Players Data
  • Create Data Objects
  • Erase Players Data
  • Update Players Data

Documentation.

Requiring The Module.

local EzData = require(ReplicatedStorage.EzData)

Initiating the module.

  • Creates a data store with a given name. (Has a default name if you do not pass one).
EzData.init("Example_Data_Store_Name")

Getting Players Data

  • Will return the players data, if it was successful( true or false), and any errors.
local PlayerData, Succ, Err = EzData.getPlayerData(Player)

Saving Players Data

  • Will return the Saved Data Table, If it was successful( true or false) and any errors.
local DataTable = {
    ["Time"] = 0,
    ["XP"] = 0,
}
local SavedData, Succ, Err = EzData.savePlayerData(Player, DataTable)

Erasing Players Data.

local DefaultDataTable = {
    ["Level"] = 1,
    ["XP"] = 0
}
EzData.erasePlayerData(Player, DefaultDataTable)

Updating Players Data

local Index = "Level"
local Value = 5
EzData.UpdatePlayerData(Player, Index, Value)

Auto-Create Data Instances.

  • Suggested to use a layout like the one in this example if you want it to automatically create leaderstats.
local PlayerData = {
    ["leaderstats"] = {
        ["Kills"] = 0,
        ["Deaths"] = 0,
    },
    ["Inventory"] = {
        ["Sword"] = true,
    }
}
EzData.loadDataInstances(Player, PlayerData)

Example
An uncopylocked place free to use.

Feedback.
Please leave any feedback and/or suggestions in the replies!

3 Likes

just a suggestion to shorten the lines at Load private function

instead of these if statements,

	local ClassType = ""
	if typeof(V) == "table" then
		ClassType = "Folder"
	elseif typeof(V) == "string" then
		ClassType = "StringValue"
	elseif typeof(V) == "number" then
		ClassType = "NumberValue"
	elseif typeof(V) == "boolean" then
		ClassType = "BoolValue"
	end

you can shorten it to

	local function title(s)
		return s:sub(1, 1):upper() .. s:sub(2, #s)
	end
	
	local _type = type(V)
	local instanceType = _type == "table" and "Folder" or `{title(_type)}Value`
    instanceType = _type == "boolean" and "BoolValue" or instanceType -- an exception cause "BooleanValue" doesn't exists

overall, :ok_hand:

Cool idea, but I don’t see any reason to use this as it just falls short in the sea of already existing datastores, like ProfileService and Datastore2.

3 Likes

just noticed that you’re not using OOP, and just setting a variable in the module to the datastoreName that has been initialized, which is a problem when you need to use more than 1 datastore (or you could require and call init for every datastore)

im confused on which one is Artzified or foodman54 as they have the same badge and pfp


I like the idea, but I can’t find a reason to use this as there’s many types of datastores like ProfileService and DataStore2

1 Like

@Artzified
I posted a v2. It uses OOP so you can use multiple data stores much more easily.

1 Like