pDataService (V1.0 | BETA)

pDataService - Advenced Data Managment for Roblox Games.

pDataService is a powerful data management module for Roblox that provides reliable data handling, automatic saving, backup functionality, and easy customization. It is designed to simplify data storage, versioning, and backup for player profiles and global data.

Please note that this module is still in BETA and may change in the future of course, every suggestion, review is aprecieted.

Roblox Marketplace Download

Developed by ParaTron Softworks.

Lead - Paradoxer

pDataService Features

  • Automatic Data Saving - Automatically saves player profiles at configurable intervals.
  • Backup System - Creates backups at set intervals to ensure data is preserved and can be restored if needed.
  • Data Validation - Ensures that default values are applied if certain data keys are missing.
  • Data Locking - Prevents data conflicts by locking profiles during critical operations.
  • Global Data Management - Provides easy handling of global data storage.
  • Customizable Save Intervals - Configure auto-save and backup intervals.

Basic Configuration

  1. Ungroup everything from folder, Instructions script is where everything is explained where to put.
  2. Open pDataService ModuleScript then change DataStoreKey to a unique string (change from "CHANGE_ME" to improve data security).
  3. Configure the AutoSaveInterval and ProfileBackupInterval values as needed.
  4. And you are done.
local pDataService = require(game.ReplicatedStorage:WaitForChild("pDataService"))
pDataService.DataStoreKey = "CHANGE_ME"
pDataService.AutoSaveInterval = 15  -- Save every 15 seconds
pDataService.ProfileBackupInterval = 600  -- Backup every 10 minutes

API

1. pDataService:GetDataStore(name)

Fetches a DataStore instance by name.

  • Parameters: name (string) - The name of the DataStore.
  • Returns: DataStore object.

Example:

local playerStore = pDataService:GetDataStore("PlayerData")

2. pDataService:LoadProfile(playerId, defaultData)

Loads a player profile with default data if no existing data is found.

  • Parameters:
    • playerId (number) - Unique ID of the player.
    • defaultData (table) - Default data to use if none exists.
  • Returns: Table of profile data or nil if already loaded.

Example:

local defaultData = { coins = 0, level = 1 }
local playerProfile = pDataService:LoadProfile(player.UserId, defaultData)

3. pDataService:SaveProfile(playerId)

Saves a player’s profile data to DataStore. Automatically updates the last saved timestamp.

  • Parameters: playerId (number) - Unique ID of the player.
  • Returns: true if successful, false otherwise.

Example:

pDataService:SaveProfile(player.UserId)

4. pDataService:ReleaseProfile(playerId)

Releases a player’s profile from memory when it is no longer needed.

  • Parameters: playerId (number) - Unique ID of the player.
  • Returns: None.

Example:

pDataService:ReleaseProfile(player.UserId)

5. pDataService:SaveGlobalData(key, data)

Saves global data that applies across sessions.

  • Parameters:
    • key (string) - Unique key for the data.
    • data (any) - Data to save.
  • Returns: true if successful, false otherwise.

Example:

pDataService:SaveGlobalData("EventStatus", { started = true })

6. pDataService:LoadGlobalData(key, defaultData)

Loads global data or applies defaults if no data is found.

  • Parameters:
    • key (string) - Unique key for the data.
    • defaultData (any) - Default data to use.
  • Returns: Retrieved data or defaultData if not found.

Example:

local eventStatus = pDataService:LoadGlobalData("EventStatus", { started = false })

7. pDataService:LockProfile(playerId)

Locks a profile to prevent other processes from accessing it until unlocked.

  • Parameters: playerId (number) - Unique ID of the player.
  • Returns: None.

8. pDataService:UnlockProfile(playerId)

Unlocks a locked profile, allowing other processes to access it.

  • Parameters: playerId (number) - Unique ID of the player.
  • Returns: None.

9. pDataService:BackupProfile(playerId)

Creates a backup of the player’s profile data.

  • Parameters: playerId (number) - Unique ID of the player.
  • Returns: None.

Example:

pDataService:BackupProfile(player.UserId)

10. pDataService:IsProfileLocked(playerId)

Checks if a player’s profile is locked.

  • Parameters: playerId (number) - Unique ID of the player.
  • Returns: true if locked, false otherwise.

Example:

if pDataService:IsProfileLocked(player.UserId) then
    print("Profile is locked.")
end

Simple Usage Examples

Here’s a complete example of how to use pDataService to manage a player’s profile data with automatic saving and locking. For example i used Coins, Levels, and playtime for basic data to store.

Step 1: Loading and Saving Player Data

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    local defaultData = { coins = 0, level = 1, playtime = 0 }
    local playerProfile = pDataService:LoadProfile(player.UserId, defaultData)
    if playerProfile then
        print(player.Name .. "'s profile loaded!")
    end
end)

Players.PlayerRemoving:Connect(function(player)
    pDataService:SaveProfile(player.UserId)
    pDataService:ReleaseProfile(player.UserId)
end)

Step 2: Using the Locking Mechanism

local function giveCoins(player, amount)
    if pDataService:IsProfileLocked(player.UserId) then
        print("Profile locked, try again later.")
        return
    end

    pDataService:LockProfile(player.UserId)
    local profile = pDataService.ActiveProfiles[player.UserId]
    if profile then
        profile.data.coins = profile.data.coins + amount
        print("Coins updated for:", player.Name)
    end
    pDataService:UnlockProfile(player.UserId)
end

Step 3: Managing Global Data

-- Setting global data for an event
pDataService:SaveGlobalData("EventStatus", { started = true, description = "Halloween Event" })

-- Loading global data
local eventStatus = pDataService:LoadGlobalData("EventStatus", { started = false })
print("Event started:", eventStatus.started)

Code Configuration

  • DataStoreKey: A unique string to prefix data entries. Changing this will reset all saved data unless updated in the DataStore.
  • AutoSaveInterval: Time (in seconds) between each automatic save cycle for player profiles.
  • ProfileBackupInterval: Time (in seconds) between each automatic backup cycle for player profiles.

Example Config:

NOTE: This configuration part can be found on top of pDataService

pDataService.DataStoreKey = "SOMETHING"
pDataService.AutoSaveInterval = 20  -- Saves every 20 seconds
pDataService.ProfileBackupInterval = 600  -- Backups every 10 minutes 

TIPS

  1. Always Set a Unique DataStoreKey: Ensure your data is isolated and secure by setting a unique DataStoreKey.
  2. Use Locking for Data Integrity: Use the locking functions when performing multiple or critical updates on profiles.
  3. Configure Save and Backup Intervals: Adjust the AutoSaveInterval and ProfileBackupInterval based on server needs and data importance.
1 Like

Is it made with profileservice? Is it any better/easier?

Nope, i wrote it in 2 3 days carefully thinking its even easy to improve it, using it is not even that hard.

1 Like

would be great if making leaderboards with it would be easier than normal datastores

Good idea i will test that feature, but i think its easy to implement

If you have any ideas for updates i would like to hear them all, it would help me improve this module i have in mind developing a plugin but i will give few updates to this.

There’s no real reason to use this over already established datastore modules unless you can show that it’s a better, more reliable option. Could you perhaps show some comparisons between your datastore module and some other commonly used ones? (such as ProfileService/ProfileStore and Suphi’s DataStore)

For the first more reliable and easier to use than the other 3 you said, and everything can be made using this made exp for storing game progress.

Well no…

For starters, with Profileservice you wrap the engine around your own wrapper which lets you do much more than what you’re currently offering.
Profileservice has auto saves features, which your option seems to lack.
With profileservice, the only thing you do is profile.Data.cash = 10 and then you don’t have to worry about anything regarding saving to datastore or profile releasing.

From there, I believe you can make a great product if only you were open to look at the different prime features of your very established “competitors”. Your product as it is currently is lacking in features and has no utility besides bare-bone saving, which the roblox api literally already provides.

Yeah i do know it has lack of features thats why it is still i BETA and now currently in work i plan to update it to 1.1 which will bring in 15 more features. But still if you can suggest something it would help me alot im not good at adding features so i much relly on users suggestions!