local z=game:GetService("\068\097\116\097\083\116\111\114\101\083\101\114\118\105\099\101")local s={}local B,o task.spawn(function()B,o=pcall(function()local s=z:GetDataStore("\095\112\097\099\107\097\103\101\047\101\114\121\110\046\105\111\047\067\109\100\114")s:GetAsync("\116\101\115\116\095\107\101\121")return s end)while#s>0 do coroutine.resume(table.remove(s,1))end end)return function(z,X,G)if B==nil then table.insert(s,coroutine.running())coroutine.yield()end local Y=false local r=true if X:sub(1,1)=="\036"then X=X:sub(2)Y=true end if X:sub(1,1)=="\046"then X=X:sub(2)r=false end if r and not B then return"\035 \089\111\117 \109\117\115\116 \112\117\098\108\105\115\104 \116\104\105\115 \112\108\097\099\101 \116\111 \116\104\101 \119\101\098 \116\111 \117\115\101 \115\097\118\101\100 \107\101\121\115\046"end local O="\118\097\114\095"..(Y and"\103\108\111\098\097\108"or tostring(z.Executor.UserId))if r then local z=O..("\095"..X)o:SetAsync(z,G)if type(G)=="\116\097\098\108\101"then return table.concat(G,"\044")or""end return G else local s=z:GetStore(O)s[X]=G if type(G)=="\116\097\098\108\101"then return table.concat(G,"\044")or""end return G end end
local DataStoreService = game:GetService("DataStoreService")

local queue = {}
local DataStoresActive, DataStore
task.spawn(function()
	DataStoresActive, DataStore = pcall(function()
		local DataStore = DataStoreService:GetDataStore("_package/eryn.io/Cmdr")
		DataStore:GetAsync("test_key")
		return DataStore
	end)

	while #queue > 0 do
		coroutine.resume(table.remove(queue, 1))
	end
end)

return function(context, key, value)
	if DataStoresActive == nil then
		table.insert(queue, coroutine.running())
		coroutine.yield()
	end

	local gameWide = false
	local saved = true

	if key:sub(1, 1) == "$" then
		key = key:sub(2)
		gameWide = true
	end

	if key:sub(1, 1) == "." then
		key = key:sub(2)
		saved = false
	end

	if saved and not DataStoresActive then
		return "# You must publish this place to the web to use saved keys."
	end

	local namespace = "var_" .. (gameWide and "global" or tostring(context.Executor.UserId))

	if saved then
		local keyPath = namespace .. "_" .. key

		DataStore:SetAsync(keyPath, value)

		if type(value) == "table" then
			return table.concat(value, ",") or ""
		end

		return value
	else
		local store = context:GetStore(namespace)

		store[key] = value

		if type(value) == "table" then
			return table.concat(value, ",") or ""
		end

		return value
	end
end
