Hello. I have an issue with a developer product, basically you can only buy it once, then if you try to purchase it again it will take your robux but give you no more in-game currency.
here is the “handler” script
local DataStoreService = game:GetService("DataStoreService")
local LeaderstatDataStore = DataStoreService:GetDataStore("LeaderstatDataStore")
local DeveloperProductID = 1597899398 -- my id
game.Players.PlayerAdded:Connect(function(player)
local Leaderstat = player.leaderstats.FairyDust
local LeaderstatKey = player.UserId .. "FairyDust"
local success, savedValue = pcall(function()
return LeaderstatDataStore:GetAsync(LeaderstatKey)
end)
if success and savedValue then
Leaderstat.Value = savedValue
end
local Purchased = false
game:GetService("MarketplaceService").ProcessReceipt = function(receiptInfo)
if receiptInfo.PlayerId == player.UserId and receiptInfo.ProductId == DeveloperProductID and not Purchased then
Purchased = true
Leaderstat.Value = Leaderstat.Value + 250
local Success, error = pcall(function()
LeaderstatDataStore:SetAsync(LeaderstatKey, Leaderstat.Value)
end)
if not Success then
warn("Failed to save leaderstat data:", error)
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end)
Please help
