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.