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

how to stop the purchase from happening twice?

so here is the code

local player = script.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:Connect(function()
	local MarketplaceService = game:GetService("MarketplaceService")
	local productID = 994379939
	MarketplaceService:PromptProductPurchase(player,productID)
	
	MarketplaceService.PromptProductPurchaseFinished:Connect(function(player, productID, isPurchased) -- isPurchased is a bool value which tells you whether or not the player purchased the product
		if isPurchased == true then -- if player purchased the product
			script.Parent.Parent.Parent.Parent.Parent.leaderstats.lives.Value = script.Parent.Parent.Parent.Parent.Parent.leaderstats.lives.Value + 10
		end
	end)
end)

what happens is that the first time they buy it, it adds 10 lives like it should then if they buy it again it increases it by 20, then 30, then 40, etc how do i make it increase by the same amount every time?

3 comments

0

You can add a debounce.

0

ok it worked

0

could you put that into an answer to mark it as answered?

2 answers

✓ Accepted answer

I believe adding a debounce should work.

1 comment

0

Yep.

Instead of adding the Value of 10, add the Value of a variable. If the currentlives + the added lives are beyond 10, set the currentlives to 10

1 comment

0

That can work as well. But if you're using it only once, you shouldn't use a variable.

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