I am using memorystoreservice but most of the code is not running.
local MemoryStoreService = game:GetService("MemoryStoreService")
local DataStoreService = game:GetService("DataStoreService")
local buyOrdersQueue = MemoryStoreService:GetQueue("BuyOrders")
local sellOrdersDataStore = DataStoreService:GetDataStore("SellOrders")
local function onBuyOrder(player, buyOrderRobotName)
local key = "R_" .. buyOrderRobotName
if key == nil then
key = "R_" .. buyOrderRobotName
end
local success, sellOrder = pcall(function()
return sellOrdersDataStore:GetAsync(key)
end)
if success then
print(sellOrder)
end
if key and key == "R_" .. buyOrderRobotName then
local addSuccess, addError = pcall(function()
buyOrdersQueue:AddAsync(key, 30, 30)
end)
if not addSuccess then
warn(addError)
end
end
while true do
pcall(function()
local robot, id = buyOrdersQueue:ReadAsync(1, false, 30)
print("Ok")
print(robot)
print(id)
if #robot > 0 then
print("39") -- Only prints to here
sellOrdersDataStore:UpdateAsync(robot[0], function(data)
print("41")
data = data or {}
data.processed = 1
print("44")
return data
end)
end
print("49")
-- Remove the robot from the queue
buyOrdersQueue:RemoveAsync(id)
print("Completed")
task.wait()
end)
end
end
workspace.Robot1PartBuy.ClickDetector.MouseClick:Connect(function(player)
onBuyOrder(player, "Robot1")
end)
workspace.Robot2PartBuy.ClickDetector.MouseClick:Connect(function(player)
onBuyOrder(player, "Robot2")
end)
workspace.Robot3PartBuy.ClickDetector.MouseClick:Connect(function(player)
onBuyOrder(player, "Robot3")
end)
It only prints to print("39")