Clover - A DataStore2 Alternative

Clover :four_leaf_clover: | by Xiko

What is Clover?

Clover offers a streamlined and simple approach to data management and is an alternative to DataStore2, offering most of the original functionality with a data removal function.


How can I get Clover?

You can use Clover and view the source code from the toolbox:


Alternatively, you can get the latest version of Clover by calling Roblox’s require function:

local cloverStore = require(107581662729608)
  • (This is because I do not have access to publish public linked packages)

Known problems and upcoming fixes

Because Clover allows you to set the store’s data to nil, data loss is possible. In later versions Clover will validate if data has loaded before allowing it to be erased.


Clover Functions:

DataStore:Set(newValue) -- Allows you to set the value of the data store
DataStore:Remove() -- Removes all data from the data store
DataStore:OnUpdate(callBack) -- Allows you to detect when the data store has been updated

How to use Clover:

In this example, I will be creating a data store that will be storing unlocked regions for a player to visit. To demonstrate Clover’s data removal feature, we will then be removing these areas.

local CloverStore = require(path.to.clover)

game.Players.PlayerAdded:Connect(function(player : Player)
	
	local unlockedRegionDS = CloverStore("UnlockedRegions", player)
	
	local joinedValue = unlockedRegionDS:Get({
		["Tutorial Area"] = true,
	});
	
	print("The current value is:", joinedValue)
	
	-- Now let's remove the data
	
	unlockedRegionDS:Remove()
	print("The current value is:", unlockedRegionDS:Get())
	
end)

Expected output:

  The current value is:  ▼  {
    ["Tutorial Area"] = true
  }  -  Server - Script:12

  The current value is: nil  -  Server - Script:17

|| Note that clover supports DataStore2’s SaveInStudio functionality, meaning if you want data to not be written or overwrote outside of the session, it will ignore the request.

3 Likes

Clover - Version 1.0.5 :four_leaf_clover:

Changes:

  • Updated the way data was saved upon player exit and server shutdowns. This fixes a potential issue where data could save twice when a player leaves.

In the next update I will look into a potential fix for overwriting data that has failed to load.

What are it’s Benefits compared to Datastore2?

better question would be “what are its benefits compared to profilestore”. datastore 2 is ancient and worse than any new open sourced datastoreservice wrapper

2 Likes