local Q=""local x=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local H={}game:WaitForChild("\078\101\116\119\111\114\107\083\101\114\118\101\114")function decodeJson(Q)local H={}pcall(function()H=x:JSONDecode(Q)end)return H end function encodeJson(Q)local H=Q pcall(function()H=x:JSONEncode(Q)end)return H end function doGet(H,q)local E=x:GetAsync(Q..("\063\115\104\101\101\116\061"..(H..("\038\107\101\121\061"..q))))local K=decodeJson(E)if K.result=="\115\117\099\099\101\115\115"then return K.value else return end end function doPost(H,q,E)local K=x:UrlEncode(encodeJson(E))local k=x:PostAsync(Q,"\115\104\101\101\116\061"..(H..("\038\107\101\121\061"..(q..("\038\118\097\108\117\101\061"..K)))),2)local O=decodeJson(k)print(k)if O.result=="\115\117\099\099\101\115\115"then return true else warn("\068\097\116\097\098\097\115\101 \101\114\114\111\114\058",O.error)return false end end function H.GetDatabase(x,Q)local H={}function H.PostAsync(q,x,H)return doPost(Q,x,H)end function H.GetAsync(H,x)return doGet(Q,x)end return H end return H
-- Touch anything below and you'll upset the script, and that's not a good thing.

local url = ""
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(sheet, key)
	local json = httpService:GetAsync(url .. "?sheet=" .. sheet .. "&key=" .. key)
	local data = decodeJson(json)
	if data.result == "success" then
		return data.value
	else
		-- warn("Database error:", data.error)
		return
	end
end

function doPost(sheet, key, data)
	local json = httpService:UrlEncode(encodeJson(data))
	local retJson = httpService:PostAsync(url, "sheet=" .. sheet .. "&key=" .. key .. "&value=" .. json, 2)
	local data = decodeJson(retJson)
	print(retJson)
	if data.result == "success" then
		return true
	else
		warn("Database error:", data.error)
		return false
	end
end

function module:GetDatabase(sheet)
	local database = {}
	function database:PostAsync(key, value)
		return doPost(sheet, key, value)
	end
	function database:GetAsync(key)
		return doGet(sheet, key)
	end
	return database
end

return module
