So i started using firebase to make backup for my game, since the free space is 1GB, that is a good start backup and have less chances to data lost (i never saw google servers down), so i will make a simple tutorial for people that are interested in using that.
I wont show my link of course.
After that you need get your token:
- Click the cog-wheel and then “Project Settings”,
- Click “Service Accounts”,
- Click “Database Secrets”,
- Click “Add Secret” and follow any steps it includes,
- Hover over your newly generated secret and click “Show”
- Click on the clipboard to copy the icon
So now lets go to script part
How get a some data:
local HttpService = game:GetService("HttpService")
local token = "" --Token you got
local databaseName = "" -- The link
local databaseFolder = "" -- The folder name (can be any name you want, but of course if dont exist on firebase will return nil)
local URL = databaseName..databaseFolder..".json?auth="..token
local Data = HttpService:JSONDecode(HttpService:GetAsync(URL))
print(Data)
That is how send some data:
local HttpService = game:GetService("HttpService")
local token = "" --Token you got
local databaseName = "" -- The link
local databaseFolder = "" -- The folder name (can be any name you want)
local URL = databaseName..databaseFolder..".json?auth="..token
local Table = {
["your table Index"] = {
["Money"] = 0
}
}
local data = HttpService:RequestAsync(
{
Url = URL,
Method = "PUT",
Headers = {
["Content-Type"] = "application/json"
},
Body = HttpService:JSONEncode(Table)
}
)
print(data)
That is how delet some data:
local HttpService = game:GetService("HttpService")
local token = "" --Token you got
local databaseName = "" -- The link
local databaseFolder = "" -- The folder name (can be any name you want, but of course if dont exist on firebase will return nil)
local URL = databaseName..databaseFolder..".json?auth="..token
local data = HttpService:RequestAsync(
{
Url = URL,
Method = "DELETE",
Headers = {
["Content-Type"] = "application/json"
},
Body = nil
}
)
print(data)