A way I can get the GUI button a player clicked without scripting each of them?

Something that I use a lot is iterate over each button in a GuiElement and use a function to bind them. There’s no need to use UIS for this

local function BindButtonToFunction(btn, func)
  btn.MouseButton1Click:Connect(func)
end

for _, v in pairs(GuiElement:GetChildren()) do
  if v:IsA("TextButton") then
    BindButtonToFuncton(btn, function()
       print(btn.Name)
    end)
  end
end
7 Likes