Hello, my script is working correctly but the data is always in a “folder” called -M… and I don’t know how to resolve this.
This is my code
local httpService = game:GetService('HttpService')
local URL = 'https://db.region.firebasedatabase.app/'
local AUTH_TOKEN = 'auth=secret'
game.Players.PlayerAdded:Connect(function(plr)
local data = {
["coins"] = 6500,
["joined"] = true
}
data = httpService:JSONEncode(data)
httpService:PostAsync(URL..tostring(plr.UserId)..".json?"..AUTH_TOKEN, data)
end)
I ended up finding a way to check the user’s data. If anyone ever needs help, this is my code:
local httpService = game:GetService('HttpService')
local URL = 'https://database.region.firebasedatabase.app/'
local AUTH_TOKEN = 'auth=xxxxxxxxxxxxxxxxxxxxxxxx'
game.Players.PlayerAdded:Connect(function(plr)
local data = {
["coins"] = 6500,
["joined"] = true,
["userId"] = plr.UserId
}
data = httpService:JSONEncode(data)
httpService:PostAsync(URL.."users.json?"..AUTH_TOKEN, data)
wait(5)
local result = httpService:JSONDecode(httpService:GetAsync(URL.."users.json?"..AUTH_TOKEN))
for _, users in pairs(result) do
for _, userData in pairs(users) do
if type(userData) == "string" then
local splitData = string.split(userData, ";")
if splitData[1] == "id" then
if tonumber(splitData[2]) == plr.UserId then
print(splitData[2])
end
end
end
end
end
end)