Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get name of player who clicked text button?

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?

1 comment

0

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

2 answers

✓ Accepted answer

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

0

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.