Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get name of player who clicked text button?

Asked by 5 years ago

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?

0
I already have the local player's name stored in a variable ElusiveEpix 2 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

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.

0
Whatever I did it myself but thanks anyway! ElusiveEpix 2 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

--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)

Answer this question