Error with Firebase API

I am using this firebase API: [Open Source] FirebaseService
This is what my db looks like:
https://cdn.discordapp.com/attachments/703110541777961020/722554867972964472/Screen_Shot_2020-06-16_at_4.55.02_PM.png

This is my script:

local HttpService = game:GetService("HttpService");
local FirebaseService = require(script.FirebaseService);
local database = FirebaseService:GetFirebase("ez-tech-whitelist");


local playerData = database:GetAsync("ezslock");
print(playerData)

Whats my issue? It prints nil

I believe the scripting support is only for lua related problems, this might be your api.

:GetFirebase() should be a table below the the whole database ez-tech-whitelist.

So if you change :GetFirebase("ez-tech-whitelist") to :GetFirebase("ezslock"), you should be able to print playerData.

local HttpService = game:GetService("HttpService");
local FirebaseService = require(script.FirebaseService);
local database = FirebaseService:GetFirebase("ezslock");


local playerData = database:GetAsync("ezslock");
print(playerData)

like that?

because it doesn’t work. it prints nil

Sorry, I mean try this.
image

local playerData = database:GetAsync();
print(playerData) -- Should be "{0}"

How can I turn “{0}” into a table instead of it being a string?

That doesn’t look like a JSON string to me. You might want to encode the table into a JSON string with Roblox’s HttpService.

So from {0} it will become [0]. Using HttpService:JSONEncode({0});
Vice versa [0] to {0}. Using HttpService:JSONDecode("[0]");

so I do
local tablet = “{0}”
tablet = http:JSONEncode(tablet)
tablet = http:JSONDecode(tablet)

Here’s a more detailed guide

local tableA = {0}; -- Your original table
local encoded = HttpService:JSONEncode(tableA); -- Turns into string "[0]"

database:SetAsync(encoded); -- saves string to database

local encodedTable = database:GetAsync(); -- Gets string table "[0]"
tableA = HttpServce:JSONDecode(encodedTable); -- Change it back to lua table, {0}
1 Like