Ooop didn’t research enough before answering, I rarely use FireAllClients, my bad. Thanks for pointing it out.
Could I have a script for that? Sorry!
The name of it is the username of the player who said “!pts” which fired the remoteevent.
This is too advanced for me and I don’t want a whole rewrite of the script, I simply just want to know how to reference the GUI element as it’s the player who said ‘!pts’ and triggered the remoteevents’ username.
It is simple… read it and you will learn from it
here is an explanation:
player types in the command, server sends info to all clients stating the username of the player who said the command, the number 0 and a random number for the password
the clients check the number and see that it is 0, so the clients create a gui and use the username for the text, then when the gui is clicked by the client, the client sends the password back to the server
the server checks the password, and if it is correct it sends back to all the clients the number “1”, the clients see that they received a 1 and delete all the GUIs they have created in regards to the script ( it knows which GUIs to delete cause they are added to a table on creation)
Alright, hmm.
I’m still confused by the case here.
- What is everything that is supposed to happen when you a player typed in the message “!pts”?
- What didn’t happen or results in error?
I tried the test game and it didn’t work.
-
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’!
-
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
- 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!