Print player name in output when a GUI button is clicked

I have a lot of panels and during my events, exploiters would mess with them. I was thinking about how do I make it print their player names on the output in all of these buttons on the GUI panels. So we would know who’s the exploiter and it would be easy for us to ban someone instead of guessing who.

3 Likes

This should work, but I’d say try and find a kind of better way to register exploiter’s names since they could just use a fake name using various scripts, and I love the Gui Design.

-- Variables
local Button =    --button location
local local_plr = game:GetService("Players").LocalPlayer

-- Event
Button.MouseClick:Connect(function()
   print(local_plr .. " has pressed the button.")
end)
5 Likes

You should use UserId rather than the name. They can change their name but they can’t change their UserId.

2 Likes

Thank you so much, but my problem is there’s a lot of buttons and I have to locate all of them manually each for the script to work. But that’s alright thank you for the help and I’m glad you like the GUIs! :laughing:

buttons = game.Workspace.Buttons:GetChildren() -- Table of the buttons

for i, v in pairs(buttons) do
  button.ClickDetector.Click:Connect(function(plr)
    print((plr.Name), " clicked " (button.Name))
  end)
end

This is for if you are using actual buttons in the game, im not sure which one you’re talking about.

2 Likes