Identifying the name of a GUI element as a players' username

  1. A GUI will pop up for all players saying ‘(USERNAME) has requested PTS!’ When someone clicks it, it will teleport them to the player and destroy the GUI for everyone. The GUI’s name will be the username of the player who said ‘PTS’!

  2. I’m trying to get help on identifying and destroying the GUI element that pops up when a player clicks the PTS request gui to answer it, and what’s making it hard is the name of it being a username of a player.

Again, this isn’t what I’m asking for.

Look at my above post for more information, but I need help on identifying the GUI element through a script to destroy it for all players and what makes that hard is that the name of it is the player who said ‘!pts’'s username. I know how to destroy it but I need help with referencing the GUI element.

Every GUI should have an accessible name of its own, especially if you plan to access them through scripts. May I ask why you need to put the GUI’s name as the username of the player who said ‘PTS’?

It’s so I can send a message using a Discord webhook from a serverscript, referencing the GUI name as the players username.

Could :FireServer return the name of the GUI element from the LocalScript to the ServerScript in some way?

:FireServer(guiElement.Name)

Name is a property of a GUI element, and many other instances. You can easily reference them in path.
So the answer is, yes.

THANKS!! This is what I needed. But, how would I take the reference and use it in a ServerScript with RemoteEvents when destroying the GUI element for everyone?

It will appear as a parameter of the OnServerEvent function.

--local script
remote:FireServer(guiElement.Name)
--server script
remote.OnServerEvent:Connect(function(player, guiName)
     print(guiName) --will print the player's name
end)

Note:-
The first parameter of OnServerEvent is always the player.

Thank you sooo much. Let me try this.

You need to test with 2 clients or you can remove line 26 in the server script, the one where it checks the player count

This worked! However, it won’t update the variable I’ve set (local name = script.Parent.Name) when the name of the GUI element changes to the player username. How would I detect when the name of it changes and update the variable accordingly?

local name = script.Parent.Name
  1. Can you show me that part of the script where you attempt to update the variable when the name of the GUI element changes to the player name?

Ah, all good now! I’ve figured it out myself. Thanks so much again for your help! :tada: