Prompting developer product issues

So my problem here is that when a player clicks an image button on a surface gui, the prompt to buy a developer product does not show. When I first made it I wanted to keep it a small script so I went with this. I have an idea of what the problem might be but even then I do not have a solution for it. All help is appreciated!

for i, v in pairs(buttons) do

	if v.Name ~= 'UIGridLayout' then
		
		v.MouseButton1Click:Connect(function()
			
			local productid = v.Value.Value
			
			productFunctions[productid] = function(receipt, player)

				MPS:PromptProductPurchase(player, productid)
				
				return true
			end
		end)
	end
end
1 Like

What is the error? Please tell us more of the context.

So what is here is a SurfaceGui with multiple buttons ranging from 10-10000. This is an excerpt of the script that is supposed to put them all together and then pick out the one that is clicked, then prompts the player with the corresponding developer product (product id is saved in an intvalue in each button). As of right now, it gives no error and does not show anything. The main problem after using printing troubleshooting seems to be between lines 4 and 11 and I cannot figure out what is wrong.

What is this bit for? Is there a StringValue object inside of v named Value? The problem seems to come from the fact you’re only defining a function when it’s clicked and not calling it. No clue why you’re doing it this way though nor how that function is supposed to get receipt and player so I can only speculate as to a change, however something like this may work:

for i, v in pairs(buttons) do

	if v.Name ~= 'UIGridLayout' then
		
		v.MouseButton1Click:Connect(function()
			local productid = v.Value.Value
			MPS:PromptProductPurchase(player, productid)
		end)
	end
end

If you must define it in the productFunctions table, then do so right above the MouseButton1Click connection and call Connect(productFunctions[productid]) instead.

1 Like