Whenever I purchase the product for the first time It only purchases it once which is demonstrated in this clip where the Product ID is printed Only Once;
However, when I purchase the product for the second time or any time that isn’t the first then it proceeds to increase in increments of 2n (n being the previous number it was before another purchase)
I don’t understand why it’s doing this as I’ve used 2 denounces to try prevent this. Here’s the Code;
LOCAL SCRIPT
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local TweenService = game:GetService("TweenService")
local PlayerService = game:GetService("Players")
local Player = PlayerService.LocalPlayer
local PlayerGui = Player.PlayerGui
local Character = Player.Character
local Assets = ReplicatedStorage.Assets
local Sounds = Assets.Sounds
local Modules = ReplicatedStorage.Modules
local Remotes = ReplicatedStorage.Remotes
local DeveloperProductsDebounce = false
for _,V in pairs(PlayerGui:WaitForChild("ScreenUI").DeveloperProducts:GetDescendants()) do
if V:IsA("TextButton") then
V.Activated:Connect(function()
if not DeveloperProductsDebounce then
DeveloperProductsDebounce = true
MarketplaceService:PromptProductPurchase(Player,V.Id.Value)
task.wait(0.15)
DeveloperProductsDebounce = false
end
end)
end
end
SCRIPT
local PlayerService = game:GetService("Players")
local MarketplaceService = game:GetService("MarketplaceService")
local ProfileService = require(game:GetService("ServerScriptService").Systems.Server.ProfileService)
local Debounce = {}
MarketplaceService.ProcessReceipt = function(Receipt)
local Player = PlayerService:GetPlayerByUserId(Receipt.PlayerId)
Debounce[Player.Name] = false
local Profile = ProfileService:GetPlayerData(Player)
while Profile == nil do
wait()
Profile = ProfileService:GetPlayerData(Player)
end
if not Player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if Debounce[Player.Name] then
else
Debounce[Player.Name] = true
print(Receipt.ProductId)
if Receipt.ProductId == 1341683158 then -- +5 Wins
Profile.Wins += 5
end
if Receipt.ProductId == 1341683194 then -- +10 Wins
Profile.Wins += 10
end
if Receipt.ProductId == 1341683231 then -- +25 Wins
Profile.Wins += 25
end
if Receipt.ProductId == 1341683428 then -- +100 Jumps
Profile.Jumps += 100
end
if Receipt.ProductId == 1341683466 then -- +250 Jumps
Profile.Jumps += 250
end
if Receipt.ProductId == 1341683524 then -- +500 Jumps
Profile.Jumps += 500
end
if Receipt.ProductId == 1341683589 then -- +1000 Jumps
Profile.Jumps += 1000
end
end
end