__________________ CACTUSBASE 2 __________________
What is CactusBase
It’s an external database module which you can use to get and edit data.
Usage
Get the CactusBase 2 ModuleScript and put it in ReplicatedStorage. Then use GetDatabase(ID, SCOPE)
to get a database for your game.
> IDs and GUIDs
TL;DR: DON’T CHANGE OR LEAK THE ID AND SCOPE AND USE A GUID.
Your ID is the id of the database, and is where data will be stored. Changing the ID or the SCOPE will cause you to lose all your data.
It’s recommanded that you use a GUID for your ID so that’s it’s much harder to access your database and data. As long as you don’t leak or give access to the ID and SCOPE of the database, it’s impossible for someone to get access to your data.
To get a GUID for your game you can use HttpService
. Run this command in the View > Command Bar
and copy paste the printed id text as your id. The harder you make it, the harder it is to crack.
print(game:GetService("HttpService"):GenerateGUID(false))
Creating a database
local CactusBase = require(game.ReplicatedStorage.CactusBase2)
local Database = CactusBase:GetDatabase("PUT_ID_HERE", "PUT_SCOPE_HERE")
Setting/Saving data
Use Database:SetAsync(key, data)
to set data. The key must be a string and the data can be any value (This includes QuickLists.) but it’s best to use dictionaries for saving data.
local res, err = Database:SetAsync("player-userId",{
Coins = 100,
Inventory = {}
})
if not res then
print('Data could not be saved:', err) -- Save error
end
Getting/Loading data
Use Database:GetAsync(key)
to get data. The key must be a string. It will return the data that was set. (If a QuickList was Set as the data only the array table will be returned, and you’ll have to make it a QuickList again.)
local data, err = Database:GetAsync("player-userId")
if not data then
print("Data could not be loaded or doesn't exist.:")
end
It’s as simple as that. Just add that into your script.
FAQs
FAQs
Can I port data from DataStoreService into CactusBase?
Not as of now, but if possible, you could get all the data of the users and use a script or command bar to set all the data to CactusBase 2 using SetAsync().
Can I use this with QuickList?
Yes, setting data is possible using my QuickList class. Unfortunately, the data returned from GetAsync()
is a dictionary and you’ll have to re-convert the returned data into a quicklist. It’s as simple as doing _( data )
. Also I don’t suggest using arrays as it’s cleaner using dictionaries.
Will this ever break?
There is a chance this might stop or break. It’s being hosted on Vercel and I have no access to the hosting part of it. All I write is the server code on how requests work to that. But if incorrect data is sent to the server, it wont break.
Can someone edit my data without permission?
As this module is open source (technically) I can’t avoid people reverse-programming the module to get access to the database. Unless they know your ID and SCOPE they wont be able to set/get any data.
Is it better than Roblox Datastore?
The saving and loading of data itself is much simpler and things such as errors are handled automatically using pcall()
. It might not be better or as secure as Roblox’s DatastoreService or things like ProfileService but it is a good alternative. It also uses Google’s Firebase for the saving and loading.