Problem with Dev Product

My developer product works perfectly fine in Roblox Studio, but in an actual instance of Roblox, it ceases to function. I have no idea why this is, as it does not product any errors in console. Keep in mind that both clients are completely unmodified.

I think it is due to debounce, because when I removed it, it functioned correctly. Only issue is that it did the function 10-15 times.

Message to prompt (if this helps):

local function onTouchTap() -- buy
	script.Parent:TweenSize(sizesmall,"Out","Quad",0.05)
	MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer, ProductID)
	wait(.05)
	script.Parent:TweenSize(default,"Out","Quad",0.05)
end

Function when bought:

local ProductID = 3155119978 -- Change this ID to your DeveloperProduct ID.
local MarketplaceService = game:GetService("MarketplaceService")
local debounce = true 

local function handlePurchase(info)
	local ReceivedProductID = info.ProductId
	local Player = game.Players:GetPlayerByUserId(info.PlayerId)

	if ReceivedProductID == ProductID then

		if Player then
			if debounce then
				debounce = false
				print(Player.Name .. " Purchased 1 Redshift's 10,000 Subscriber Award")
				local clone = script.ParticleEmitter:Clone()
				local clone2 = script.PointLight:Clone()
				clone.Parent = workspace[Player.Name].HumanoidRootPart
				clone2.Parent = workspace[Player.Name].HumanoidRootPart
				game.ReplicatedStorage.RemoteEvent:FireAllClients(Player)
				game.ReplicatedStorage.Thankyou:FireClient(Player)
				game.ReplicatedStorage.Thankyou2:FireAllClients(Player)
				game.ReplicatedStorage.Trophy:Clone().Parent = Player.Backpack
				debounce = true
				wait(10)
				clone.Rate = 0
			end
		end
	end
end

MarketplaceService.ProcessReceipt = handlePurchase

Roblox Studio:


Roblox Client:

2 Likes

Maybe put the debounce thing all the way to the end of the code? Atleast thatโ€™s how it looks in my scripts

Or try to print out all values that cannot be found, maybe youโ€™ll see the actual problem

Oh and btw: there can be something with the way youโ€™re checking gor user buying the devproduct. Iโ€™d put the remoteEvent to assign the other part of the code.

Do not use workspace[player.Name] to reference a playerโ€™s character. Player instances have a โ€œCharacterโ€ property which holds a reference to their character model in Workspace. You do not need a debounce either. MarketplaceService.ProcessReceipt does not execute more than once per transaction

debounce is a global variable. If multiple players purchase at the same time, it causes an error.

implement a player debounce using a table.

you also set debounce = true before the wait(10) call. other purchases could be triggered during the waiting period.

local playerDebounce= {}

if not playerDebounce[player.UserId] then
  playerDebounce[player.UserId] = true
--
--
--
  task.wait(10)
  playerDebounce[player.UserId] = nil -- reset debounce after delay
end
1 Like

wait is also deprecated. Use task.wait

I just brought it from the original script so he can understand it easily. But sure

also need to return the enum for success as stated in the document

After returning Enum.ProductPurchaseDecision.PurchaseGranted with pcall and using 1NoFreeโ€™s debounce, I managed to get the script working.

You dont need to use pcall function for Enum.ProductPurchaseDecision.PurchaseGranted and Enum.ProductPurchaseDecision.NotProcessedYet.

And please mark the solution that actually worked as a solution.

1 Like

:+1:ุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœุœ

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.