I’m attempting to create a button that prompts a product, however, it won’t work. I’ve never run into this issue before nor have I ever really used a SurfaceGui to prompt products with a button. Can anyone help me solve this issue?
Code:
local MarketPlaceService = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
for _,v in pairs(script.Parent.Parent.ButtonContainer:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
MarketPlaceService:PromptProductPurchase(Player, v.ProductId.Value)
end)
end
end
The code itself is good - I tested it and I got the button to work.
Is the script a child of the workspace? Local scripts won’t run inside of the workspace.
If you’re cloning the gui into the workspace, make sure to check you’re connecting the MouseButton1Click event to the cloned gui, and not the original gui.