So, I’m currently trying to make a discord bot database that can ban people with a reason in my roblox game.
Everything works, but I just can’t seem to get another column. Which is the “reason” for ban.
I’ve tried to get all the data in the google spreadsheet, but it just keep saying an error.
GoogleSpreadSheet: https://imgur.com/TgBoOnU
ServerScript Code (Location: game.ServerScriptService):
for _,player in pairs(game.Players:GetChildren()) do local ReValue = globalDatabaseGlobal:GetAsync(player.UserId) local banTable = ReValue:GetAsync(player.UserId.."reason") local reason = banTable[1] if ReValue == true then player:Kick("You've been banned by Console. Reason: "..reason[1]) end end
ModuleScript Code (Location: game.ServerScriptService.ServerScript):
local Global = --// MADE EMPTY FOR PRIVACY REASONS local URL = "https://script.google.com/macros/s/" .. Global .. "/exec" local httpService = game:GetService("HttpService") local module = {} game:WaitForChild("NetworkServer") function decodeJson(JSON) local jsonTab = {} pcall(function() jsonTab = httpService:JSONDecode(JSON) end) return jsonTab end function encodeJson(data) local jsonString = data pcall(function() jsonString = httpService:JSONEncode(data) end) return jsonString end function doGet(GoogleSheet, KeyID, reason) local JSON = httpService:GetAsync(URL .. "?sheet=" .. GoogleSheet .. "&key=" .. KeyID) local data = decodeJson(JSON) print(JSON) if data.result == "success" then return data.value else return end end function doPost(GoogleSheet, KeyID, data) local JSON = httpService:UrlEncode(encodeJson(data)) local RTJSON = httpService:PostAsync(URL, "sheet=" .. GoogleSheet .. "&key=" .. KeyID .. "&value=" .. JSON, 2) local data = decodeJson(RTJSON) if data.result == "success" then return true else return false end end function module:GetDatabase(GoogleSheet) local database = {} function database:PostAsync(KeyID, value) return doPost(GoogleSheet, KeyID, value) end function database:GetAsync(KeyID) return doGet(GoogleSheet, KeyID) end return database end return module
(ps I am not good with HTTP stuff. Any help would be appreciated!)