Can't fix my automatic Dev Product!

I am working on a automatic donate buttons. It works but it only displays one product prompt. I have 6 donate buttons and 6 dev products. However, when I click the other buttons. It displays only “25” robux dev product. I am sorry if this is confusing!

local MPS = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
local Buttons = script.Parent:GetDescendants()

for i, v in pairs(Buttons) do
	if v:IsA("TextButton") then
		v.MouseButton1Down:Connect(function()
			for i, product in pairs(Buttons) do
				if product:IsA("IntValue") then
			
					MPS:PromptProductPurchase(plr, product.Value)
					print(product.Value)
				end
			end
		end)
		
	end
	
end
1 Like

Can you share the workspace layout of all the instances involved please? It seems like you are currently telling it to make multiple PromptProductPurchases per button click.

1 Like

That’s the problem. I want it to make only 1 PromptProductPurchases per button click.

Just add a break.

for i, product in pairs(Buttons) do
				if product:IsA("IntValue") then
			
					MPS:PromptProductPurchase(plr, product.Value)
					print(product.Value)
                   break
				end
			end
1 Like

Rather than using GetDescendants() it makes more sense to use GetChildren() for the outer loop.

The inner for loop isn’t necessary as the dev product id can be found by doing v.PASS

1 Like

This won’t work as it will break after the same dev product id for every button so you’d still get all buttons causing the same prompt

Switch out GetDescendants() to GetChildren()?

Yep there is no need for GetDescendants as you know the buttons are direct children of the scrolling frame.

I have tried it. Now it doesn’t prompt anything


local MPS = game:GetService("MarketplaceService")
local plr = game.Players.LocalPlayer
local Buttons = script.Parent:GetChildren() -- edit 1

for i, v in pairs(Buttons) do
	if v:IsA("TextButton") then
		v.MouseButton1Down:Connect(function()
			local passInfo = v.PASS -- edit 2
			
			MPS:PromptProductPurchase(plr, passInfo.Value)
			print(passInfo.Value)
				
			
		end)
		
	end
	
end

1 Like

Ah, I only switched out Edit 1. Maybe that is why

Thank you!!! I wouldn’t have figured it out without your help! Now I’ll go back working on my game! I appreciate you

1 Like

This fixed of calling multiple products but didn’t work but thank you for trying!

I didn’t really understand what you meant so… lol

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