The :GetChildren() function returns a table that you can index with number values. (See here more information). You also can get rid of the curly brackets around it and try using .Activated unless you have your own reason for using .MouseButton1Click. Try this instead:
local gameMap = script.Parent.Parent.GameMap
local buttons = gameMap:GetChildren()
for _, button in ipairs(buttons) do
button.Activated:Connect(function()
print(button.Name)
gameMap.Visible = false
end)
end
I would like to press the button open map and that the image becomes visible, then if I press a locationbutton then the image and its childrens go visible false
local gameMap = script.Parent.Parent:WaitForChild("GameMap")
local buttons = gameMap:GetChildren()
script.Parent.MouseButton1Click:Connect(function()
gameMap.Visible = true
end)
for i, v in pairs(buttons) do
v.MouseButton1Click:Connect(function()
print("Location "..i)
gameMap.Visible = false
end)
end