Tutorial how to use firebase, Clear and Simple

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:

  1. Click the cog-wheel and then “Project Settings”,
  2. Click “Service Accounts”,
  3. Click “Database Secrets”,
  4. Click “Add Secret” and follow any steps it includes,
  5. Hover over your newly generated secret and click “Show”
  6. 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)
17 Likes

Wow, but it can be done type “I like”, if you don’t understand it is like when you click one is added in the database
and its update in all servers

Can you be more clear possible? iam brazilian, so i dont understand some things.

1 Like

oh, Pode ser feito como um banco de dados quando você clica para atualizá-lo com aquela página da web? (traduzido em tradutor, desculpe)

2 Likes

I think that can since is a Realtime Database, iam just using for backup, like if the player leave and the datastore fail to save so i send a copy for firebase, so when player join again i check if have any data on firebase with the player userid, if have i get,save on datastore than delete from firebase

2 Likes

ah, thanks for this tutorial, I will use it for the future :smiley:

1 Like

Sorry for annoying you but, this is better suited for #resources:community-tutorials.

(Desculpe por incomodá-lo, mas isso é mais adequado para #resources:community-tutorials.)

2 Likes

You might want to crop out the name on the Zoom meeting as thats information that shouldn’t be on the DevForum.

3 Likes

There is nothing hre though.

it got deprecated, click on learn more.


It is formatted in the weirdest way possible so I am confused.

hmm i mean, iam not experiencied with the firebase configurations etc, if they changed that i need look, but you just need your database TOKEN, idk if they changed the TOKEN method, i will take a look and i will alert you if i found something

SO AFTER A LONG TIME I FOUND WHY @FelixProfit they changed how get the token on firebase