Buy Coins GUI not working as intended

Trying to make a buy coins GUI and the button for different products is showing the last ID and isn’t showing any others… Also it isn’t showing the name of the product only the ID of the product.

Photo

Code
local DevProducts = {1230421676, 1230421820, 1230421884, 1230421918}
 
local Player = game.Players.LocalPlayer
 
local MarketplaceService = game:GetService("MarketplaceService")
 
local ProductFrame = script.Parent.DonateFrame
local SampleButton = ProductFrame.SampleButton
 
function setupProducts()
    for i = 1, #DevProducts do
        local ProductsId = DevProducts[i]
        
        local ProductData = MarketplaceService:GetProductInfo(ProductsId, Enum.InfoType.Product)
        local ProductPrice = ProductData.PriceInRobux
 
        local ProductSlot = SampleButton:Clone()
        local PurchaseButton = ProductSlot
 
        ProductSlot.Parent = ProductFrame
        ProductSlot.Name = ProductsId
        
        local ProductName = ProductSlot.Name
 
        PurchaseButton.Text = "Buy " .. ProductName .. "for" .. ProductPrice .. "R$"
 
        PurchaseButton.MouseButton1Click:Connect(function()
            MarketplaceService:PromptGamePassPurchase(Player, ProductsId)
        end)
    end
 
    SampleButton:Destroy()
end
 
setupProducts()

3 Likes

Are you sure its a gamepass? If its not, use MarketplaceService:PromptProductPurchase(). If its a gamepass, remake it as a developer product.
Also I don’t see a variable named DevProducts, that you are using in a loop.

1 Like

I changed MarketplaceService:PromptGamePassPurchase(Player, ProductsId) to MarketplaceService:PromptProductPurchase(Player, ProductsId)

But It doesn’t prompt the purchase and it isn’t showing the name of the product only the ID of the product in the button… :confused:

  1. To fix the name issue replace "Buy "..ProductName with "Buy "..ProductData.Name
  2. The frames have the same position causing them to hide behind each other(you may want to use a UIListLayout or position them with code).

It works now, thanks!

(3O chars)