This keeps adding more than 10 like its suppose to... I've had this problem for many days and I can't find out why..
server script :
local DataStore = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local MarketService = game:GetService("MarketplaceService") local productId = 23429504 function CompletePurchase(player) local stats = player:WaitForChild("leaderstats") local cash = stats:WaitForChild("Cash") local debounce = true cash.Value = cash.Value + 10 end MarketService.ProcessReceipt = function(receiptInfo) for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then local ID,PROD = receiptInfo.PlayerID, receiptInfo.PurchaseId if receiptInfo.ProductId == productId then CompletePurchase(player) end end end local playerProductKey = "plr_" .. ID .. "_pur_" .. PROD DataStore:IncrementAsync(playerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGranted end
just incase you need this script : server script
local player = game.Players.LocalPlayer local credits = game.StarterGui.MainGuis.Shop.Credits game.Players.PlayerAdded:connect(function(player) local stats = Instance.new("Folder",player) stats.Name = 'leaderstats' local cash = Instance.new("IntValue",stats) cash.Name = "Cash" cash.Value = 10 credits.Text = "Cash: "..player.leaderstats.Cash.Value..'$' end)
promptpurchase script : local script
local buy = script.Parent local productId = 23429504 enable=true buy.MouseButton1Click:connect(function() if enable==true then enable=false game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) enable=true end end)
Basic additions. Just add local debounce = false
anywhere, make sure to put if debounce == false then debounce = true
above where the problem is and at the end of the if
statement, add debounce = false
EDIT: (P.S. Sorry, I didn't realize that somebody else posted that :/)