EasyProfileStore | Simplifying ProfileStore

🤔EasyProfileStore🛠️

Easy-to-use ProfileStore library

GET HERE!

What is it?

EasyProfileStore is a lightweight wrapper built on top of ProfileStore.

It does not replace ProfileStore or modify its core functionality — instead, it provides a simplified interface to make it easier to use, especially for developers who want a cleaner and more straightforward setup.

This module was created to reduce the amount of boilerplate and repetitive code required when working directly with ProfileStore.

How is it used?

It is currently designed for server-side use only.
This helps keep your game’s data more secure.
Below are the features this module offers:

API

EasyProfileStore.New(databaseName, template)
Creates a new database. The template must be a table containing the default player data.

EasyProfileStore.onPlayerJoined(callback)
Fires when a player joins and their data is successfully loaded. Returns the Player and their profile.

EasyProfileStore.onPlayerRemoved(callback)
Fires when a player leaves. Data is saved and the session is ended automatically.

EasyProfileStore:PublishMessage(userId, messageTable)
Sends a cross-server global message to a specific player (even if they are offline).

EasyProfileStore.SuscribeMessage
Event that fires when a cross-server message is received. You must call processed() after handling it.

EasyProfileStore.OnError
Fires if an internal error occurs.

Example Code
-- Calling the module
local EasyProfileStore = require(game.ReplicatedStorage.EasyProfileStore)

-- creating new db
EasyProfileStore.New(
	"NameDB", -- Name of the database
	{ -- Template of the database (Must be a table)
		Coins=0;
	}
)

-- Player removed and data saved automatically
EasyProfileStore.onPlayerRemoved(function(plr)
	print("Player leave game: ",plr.Name)
end)

-- Player joined and data loaded
EasyProfileStore.onPlayerJoined(function(plr,dataLoaded) -- Player instance and table with info.
	print("PLAYER: ",plr.Name)
	print("DATA:",dataLoaded)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr
	
	local Coins = Instance.new("IntValue")
	Coins.Name = "Coins"
	Coins.Value = dataLoaded.Data["Coins"]
	Coins.Parent = leaderstats
	
	-- Saves the coins value when it changes
	Coins.Changed:Connect(function()
		dataLoaded.Data["Coins"] = Coins.Value
	end)
	
	task.delay(5,function()
		-- Sends a cross-server global message to a specific player. 
		-- This can be used to queue notifications, rewards, or updates that will be delivered when the player joins
		EasyProfileStore:PublishMessage(plr.UserId,{Type="Coins",Amount=100})
	end)
	
end)

-- Display error on console if something went wrong
EasyProfileStore.OnError:Connect(function(errorMessage)
	warn("ERROR: ", errorMessage)
end)

-- Suscribe to cross-server global messages
EasyProfileStore.SuscribeMessage:Connect(function(Player,message,proccesed)
	print("PLAYER: ",Player.Name)
	print("MESSAGE: ",message)
	
	if message["Type"] == "Coins" then
		local CoinsValue = message["Amount"]
		
		local leaderstats = Player:FindFirstChild("leaderstats")
		if leaderstats then
			local Coins = leaderstats:FindFirstChild("Coins")
			if Coins then
				print("Agregando monedas")
				Coins.Value += CoinsValue
			end
		end
		
	end
	
	-- You must call this function to mark the message as processed
	proccesed()
end)

Credits

6 Likes

I’m not sure what part of ProfileStore you think has so much boilerplate and repetitive code that you think it needs a wrapper

3 Likes

This module is somewhat more superficial than the rest; it is designed for quick installation and fast, uncomplicated use without API complications for beginners

1 Like

man we wrapping wrappers now, profilestore is already pretty simple so if someone wasn’t able to learn it nor make their own then looking for wrappers of wrappers should probably not be their priority but rather go back to the documentation / tutorials they skipped

Dosent look that bad, its actually pretty useful and a more intuitive than ProfileStore itself.