Send Name to function

Could i also make it so that every button what got clicked runs local function buttonClicked(NameOfButton)

You just need to set the rest of the buttons with HookButton(buttonName, theFunctionToCall)

Okay thanks for ur help


if you have a bunch of buttons and want each one to get detected once pressed then you can do this

for i,v in pairs(script.Parent:GetChildren()) do -- AllOfYourButtonsSpot
if v:IsA("Button")
v.MouseButton1Click:Connect(function()
print(v.Name)
end
end)

Okay thanks and i have another question, for what do i need Callback and Callback(ButtonName) can i remove it?

local function HookButton(Target, Callback)
local ButtonName = Target.Name
local HookFunction = function()
Callback(ButtonName)
end
return Target.MouseButton1Click:Connect(HookFunction)
end