Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my dev product buy multiple times after I buy it once?

I have a game and the currency is called LiBux and I have a gui that when you click it a dev product shows up to buy it. When you buy it, it gives you +1 LiBux. When you buy it agian it gives you +2. When you buy it again you get +3 and so on. Why does it do this? I want it to be when you buy it you only get +1.

Here is the script in the TextButton

local button = script.Parent
local id = 269243771

button.MouseButton1Click:connect(function()
	game:GetService('MarketplaceService'):PromptProductPurchase(game.Players.LocalPlayer, id)
end)

here is the script in ServerScriptService

local MarketplaceService = game:GetService("MarketplaceService")
local id = 269243771

MarketplaceService.ProcessReceipt = function(receiptInfo)
 for i, player in ipairs(game.Players:GetChildren()) do
  if player.userId == receiptInfo.PlayerId then
   if receiptInfo.ProductId == id then
	
	player.leaderstats.LiBux.Value = player.leaderstats.LiBux.Value + 1
   end 
  end
 end
end

2 comments

0

You don't return a result in ProcessReceipt

0

can you give me an example in answers section?

1 answer

Uhhh, Maybe try X + 1 and set the value of X to 0 by doing x = 0 I am not an expert or anything I'm just trying to help :P

This discussion is preserved as it was. New answers, comments, and votes are closed.