I wanted a remote event to fire only if I myself clicked it. In the MouseButton1Click event, how do I get the name of the player?
How to get name of player who clicked text button?
2 answers
You have to use a local script for gui stuff(in your example button clicking).
in local script just define LocalPlayer and on MouseButton1Click event just check if local player's name is the same as your username.
Then just fire a remote to server. If you want more security you can fire a remote every time a player clicks a button and then check on server if player's name is your username, but that's less effective.
1 comment
Whatever I did it myself but thanks anyway!
--Make this a LocalScript inside of the button script.Parent.MouseButton1Click:Connect(function() local player = game.Players.LocalPlayer if player.Name == "" then -- put ur name in quotes game.ReplicatedStorage.RemoteEvent:FireServer() end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I already have the local player's name stored in a variable