Hello, I made an product script for an donate gui, I tried to buy my product but there was an error. What is the error in my script? I think i am true but,
local Player = game:GetService("Players").LocalPlayer local MarketplaceService = game:GetService("MarketplaceService") for _, thing in pairs(script.Parent:GetChildren()) do if thing.ClassName == "TextButton" then thing.MouseButton1Click:Connect(function() MarketplaceService:PromptProductPurchase(Player, thing.ID.Value) end) end end
Try to make pairs in a function That helps me
local Player = game:GetService("Players").LocalPlayer local MarketplaceService = game:GetService("MarketplaceService") function press_btn() -- Creates a function for _, thing in pairs(script.Parent:GetChildren()) do if thing.ClassName == "TextButton" then thing.MouseButton1Click:Connect(function() MarketplaceService:PromptProductPurchase(Player, thing.ID.Value) end) end end end press_btn() -- Starts a function