game.MarketplaceService.ProcessReceipt = function(reciptInfo) local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId) if reciptInfo.ProductId == 1166140314 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 50 elseif reciptInfo.ProductId == 1166140360 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 100 elseif reciptInfo.ProductId == 1166140438 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 250 elseif reciptInfo.ProductId == 1166140622 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 500 elseif reciptInfo.ProductId == 1166140682 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 1000 end end
for some reason, when i buy something, for example the first one, it adds 50 tokens. But when i buy it again, it adds 100 tokens. and when i buy it for the third time, it add 150 tokens this time. It seems like it's adding 50 to every thing. how do i fix this?
game.MarketplaceService.ProcessReceipt = function(reciptInfo) local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId) if reciptInfo.ProductId == 1166140314 then plr.leaderstats.Tokens.Value += 50 return -- would it fix if you put a return after every purchase? or try PromptProductPurchaseFinished cos pro :) elseif reciptInfo.ProductId == 1166140360 then plr.leaderstats.Tokens.Value += 100 elseif reciptInfo.ProductId == 1166140438 then plr.leaderstats.Tokens.Value += 250 elseif reciptInfo.ProductId == 1166140622 then plr.leaderstats.Tokens.Value += 500 elseif reciptInfo.ProductId == 1166140682 then plr.leaderstats.Tokens.Value += 1000 end end
Thanks! I used return but modified it a bit for it to work! Here's the finalized code.
game.MarketplaceService.ProcessReceipt = function(reciptInfo) local plr = game.Players:GetPlayerByUserId(reciptInfo.PlayerId) if reciptInfo.ProductId == 1166140314 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 50 return Enum.ProductPurchaseDecision.PurchaseGranted elseif reciptInfo.ProductId == 1166140360 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 100 return Enum.ProductPurchaseDecision.PurchaseGranted elseif reciptInfo.ProductId == 1166140438 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 250 return Enum.ProductPurchaseDecision.PurchaseGranted elseif reciptInfo.ProductId == 1166140622 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 500 return Enum.ProductPurchaseDecision.PurchaseGranted elseif reciptInfo.ProductId == 1166140682 then plr.leaderstats.Tokens.Value = plr.leaderstats.Tokens.Value + 1000 return Enum.ProductPurchaseDecision.PurchaseGranted end end