So recently I have been working a ton on scripts and datastores and I’ve been having one problem coming along it.
Datastore Request Was Added To Que
Now I have been looking at plenty and I mean plenty of scripts, and ways of going around this, but I still have no clue why its being added to queue?
- Could it be to many datastores?
- Can’t process right?
- Have no idea…
Here is my script and Idea ive been working on: Just a basic cash gui, and yes my local button does process the receipt and does test purchases with robux, but it gets added to que -
--[ WATCH TWINPLAYZ ON YOUTUBE FOR HELP ON THIS ]--
--[ SERVICES ]--
local MarketplaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
--[ LOCALS ]--
local productID = 1151442969 -- product id 1
local productID2 = 1154062158 -- product id 2
--[ FUNCTIONS ]--
local function processReceipt(receiptInfo)
local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
MarketplaceService.ProcessReceipt = processReceipt
if not player then
-- player probs left game
-- if back then call again
print("not processed")
return Enum.ProductPurchaseDecision.NotProcessedYet
end
-- If they bought it
if receiptInfo.ProductId == productID then
-- checks to make sure its a player
if player then
player.Cash.Value = player.Cash.Value + 10 -- adds 10 cash.
print(player.Name.. " just bought " .. receiptInfo.ProductId)
end
elseif receiptInfo.ProductId == productID2 then
-- checks to make sure its a player
if player then
player.Cash.Value = player.Cash.Value + 20 -- adds 20 cash.
print(player.Name.. " just bought " .. receiptInfo.ProductId)
end
end
-- returns it as purchase completed.
return Enum.ProductPurchaseDecision.PurchaseGranted
end
And here is my Minute Leaderboard or leaderstats you can call. That normally does all the saving.
This script works perfectly fine :
--[[
@author TwinPlayzDev_YT
@since 1/28/2021
This script will save and put minutes on the leaderboard. You can change minutes to anything--
you would like just simply read the code and look at Minutes.Name = "Minutes" change "Minutes"
to anything like "Points", "Level", etc. Please watch my youtube tutorial if needed.
--]]
--[ SERVICES ]--
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("TimeStats")
local service = game:GetService("MarketplaceService")
--[ LOCALS ]--
local VIPGamepassId = 13913938 -- VIP GAMEPASS ID
local GamepassId = 13914120 -- GAMEPASS ID
--[ FUNCTIONS ]--
game.Players.PlayerAdded:Connect(function(Player)
--[{ LEADERSTATS }]--
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = Player
local Minutes = Instance.new("IntValue")
Minutes.Name = "Minutes" -- changing name here (points, levels, time, etc.)
Minutes.Value = 0 -- default value
Minutes.Parent = Leaderstats
local Cash = Instance.new("IntValue")
Cash.Name = "Cash" -- changing name here (points, levels, time, etc.)
Cash.Value = 0 -- default value
Cash.Parent = Player
--[{ DATA STORE }]--
local Data = DataStore:GetAsync(Player.UserId) -- Get Data
if type(Data) ~= "table" then
Data = nil
end
if Data then
Minutes.Value = Data.Minutes
Cash.Value = Data.Cash
end
local incrementValue = 1 -- value when adding points
if (service:UserOwnsGamePassAsync(Player.UserId, VIPGamepassId)) then -- 3x gamepass
incrementValue = 3
elseif (service:UserOwnsGamePassAsync(Player.UserId, GamepassId)) then -- 2x gamepass
incrementValue = 2
end
--[{ TIME GIVERS }]--
coroutine.resume(coroutine.create(function() -- gives 1 point every minute
while true do
wait(60) -- every minute
Minutes.Value = Minutes.Value + incrementValue -- adds points based off of the incrementValue
end
end))
coroutine.resume(coroutine.create(function() -- gives 1 point every minute
while true do
wait(120) -- every 2 minutes
Cash.Value = Cash.Value + incrementValue -- adds cash
end
end))
end)
game.Players.PlayerRemoving:Connect(function(Player) -- save function here
--[{ DATA STORE SAVING }]--
DataStore:SetAsync(Player.UserId, { -- gets data
Minutes = Player.leaderstats.Minutes.Value,
Cash = Player.Cash.Value
})
end)