Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Saying Buttons isnt a Valid member of ScreenGui?

Asked by
22To 70
8 years ago

I really dont know why TBH because it obviously is.

for i,v in pairs(script.Parent.Buttons:GetChildren()) do
    if v:isA("TextButton") then
        v.MouseButton1Click:connect(function()
            pcall(function()
                if v:FindFirstChild("Pass") then
                    game.MarketplaceService:PromptPurchase(game.Players.LocalPlayer,tonumber(v.Name))
                else    
                    game.MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer,tonumber(v.Name))
                end
            end)
        end)
    end
end

Location: https://gyazo.com/edb8f8fc8e2a1c4ca9fc966d13ea26be

1 answer

Log in to vote
0
Answered by 8 years ago
script.Parent:WaitForChild("Buttons")
for i,v in pairs(script.Parent.Buttons:GetChildren()) do
    if v:isA("TextButton") then
        v.MouseButton1Click:connect(function()
            pcall(function()
                if v:FindFirstChild("Pass") then
                    game.MarketplaceService:PromptPurchase(game.Players.LocalPlayer,tonumber(v.Name))
                else    
                    game.MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer,tonumber(v.Name))
                end
            end)
        end)
    end
end

Ad

Answer this question