So I made a ClickDetector that fires a RemoteEvent in client. When that RemoteEvent is fired, it fires another one to server:
this is the second remote event script that works when the previous one is fired:
The thing is I want it to work for only the player that initially used the ClickDetector instead of showing up the ui to everybody. How do I do that? I thought of somehow making the first RemoteEvent script save the player name, and then make the second RemoteEvent script pop up the ui to the name that was saved, but I don’t know how to move those strings from event to event, and if it would work.
If anyone knows how to do it, or thinks they can help, I’d really appreciate it!
The server can’t access PlayerGui, just looping through the players on the client and changing the ui
Edit: didn’t read the last part sorry, instead of firing to the client and then to the server, just fire to the client (the one that pressed the button) and change the ui
Why are you doing a Client → Server → Client type of communication when you all you need to do is have a Server → Client.
The server detects and verifies when the ClickDetector is clicked → The server fires all clients displaying whatever you need it to.
You don’t need to repeat your code using the if statement if its exactly the same. You can pretty much just do:
if player.PlayerGUI:FindFirstChild("Santa") then
player.PlayerGui.Santa:Destroy()
end;
-- continue the rest of your code here
As stated in point number 1, you can pretty much do all of this on the client and instead of having a script and ServerEvent. You can have a local script, etc