Shortening script efficiently to not repeat for each gui button

I want to learn how to change my script to not have repetitive lines and print the name of the button I press

local frame = script.Parent

for i, v in frame:GetChildren() do
   if v:IsA("GuiButton") then
       v.Activated:Connect(function()
       print(v.Name)
       end)
   end
end
1 Like