When I test-buy a developer product I made, each time I buy it, the rewards presented by it double.
My code works this way:
- LocalScript determines that player wants to purchase product; uses RemoteEvent to send message and Developer Product ID to a script in ServerScriptService
- Server Script in ServerScriptService prompts purchase to player
- If purchase is successful, 25 Gold is rewarded to player
That’s at least what it ideally should be. What I mean by the rewards doubling is that when I purchase it for the first time, it rewards me with 25 Gold. If I try to purchase it a second time, it rewards me with 50. Then, it adds 75 more when I buy for the 3rd time. That sequence continues every time I try playing, so my Gold stats go from 0 -> 25 -> 75 -> 150.
The reason I put it in Scripting Support instead of a Bug section is because I think I’m doing something wrong on my end; that’s what the case usually is. Anyways, back to the description.
This is the code in my LocalScript:
local AddGold = game.ReplicatedStorage.DevProduct_AddGold local devProductID = script.Parent.Parent.DevProductID script.Parent.Activated:Connect(function(player) AddGold:FireServer(devProductID.Value) end)
Here is the code in the Script in ServerScriptService:
local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players") game.ReplicatedStorage.DevProduct_AddGold.OnServerEvent:Connect(function(player, devProductID) MarketplaceService:PromptProductPurchase(player, devProductID) local leaderstats = player.leaderstats local gold = leaderstats.Gold MarketplaceService.PromptProductPurchaseFinished:Connect(function(userId, productId, isPurchased) if isPurchased then if productId == 998890745 then gold.Value = gold.Value + 25 end end end) end)