Firebase Database Tutorial

Want to implement Firebase to your Roblox game? Follow this!

The things you’ll need to get this set up are:
* Your firebase URL. - If you’re in your realtime database, you’ll be able to find it here:

* Next, your auth token. To find this, there’s a few more steps, they are the following.

** Head over to project settings:

image

** Select Service Accounts:

image

** Click on database secrets:

image

** And finally, copy your auth token

Download the Roblox studio file I’ve attached to this message, it has the needed modules and examples.

FirebaseTemplate.rbxl (22.0 KB)

We’ll start off by getting everything set up.

** Head over to ServerScriptService and go into FirebaseService:

image

** From above, put in your auth token and database URL:

Alright, now we’ll head over into DBHandler

** Start off by putting in where you want to save the data. Ex. ___ Game:

image

** I’ve set up some notes inside the script, basically guiding you. Follow and fill anything that may be needed.

If you need any other help or have questions, let me know and I’ll try to help you!

Credits: @MXKhronos (Firebase Module)

18 Likes

Like what is the purpose of this script? @asd_bee? can you say me it?

Roblox’s datastore service isn’t to to secure. It also will completely stop saving data if too many data save requests are sent. However HTTPS service can fire much more requests. I believe Roblox datastores also have a limit to how much can be saved in there (not 100%).

3 Likes

Oh MK. That will b usefull for my building system it saves every time when u press close button

Yeah, there is a DataStore limit.

2 Likes

How would I get already existing user data?

there’s an example in the .rblx file

Sorry, I didn’t phrase that right. I meant as a single value. If I do print(getData), it’ll print the entire table, but I instead want to print one item from the table, like this: print(getData[1]). I tried this and it returned as ‘nil’. How would I print out a singular defined value?

because that’s not how you get data

.userID to get the user ID and so forth

Hello, nice tutorial! I am a noob at firebase and I am trying to learn firebase too. I have just a couple of questions for you;

  1. Let’s say I wanted to get if a player if banned, or not; How would I do that?
  2. Let’s say if a person buys a gamepass or a developer product, How would I do that to send via firebase as a “True” statement?

I’ve figured how to do UserIds and player names; Just need help with these! Thank you again for doing this.

  1. You’d save the data, ex:
    local data = { banned = [banned], reason = 'oh' }

then, inside of a PlayerAdded event,

local getData = database:GetAsync(p.UserId)
if (getData == nil) then 

elseif (getData ~= nil) then
if (getData.banned == true) then
p:Kick(getData.reason)
end
end

or something like that

  1. just create another data variable ex. premium, use marketplaceservice to see if they own the gamepass, (if they do it returns true iirc)

let me know if i explained something wrong or if you still need help

No, I don’t mean that. I mean if a player is ban, let’s say with Adnois or another admin command or, something like that. Sorry for the confusion.

I believe all of those admin systems use some type of datastore, so you’d have to go into datastores to find bans or get data from the admin systems

Thank you! Lastly, how do I update a players’ firebase profile if they are banned or changed username’s or something like that? Wouldn’t be in the PlayerRemoving correct?

You can put it in that event, or a replicated event.

How would I do that? You mean like fireclients etc?

Please check your messages, I’ve sent you stuff that I need help with.

Hi, the way you are using (database secrets) is actually deprecated now, so I advise you to either close it or update it. Hope this helps.

1 Like

Hi, do you have any idea how to update it using Firebase Admin SDK? Thanks

No, if I did I would have definitely done that though, and will if I do.