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

How do I get the name of the player who clicked a button with a normal script?

Asked by 3 years ago

So I'm making a button where you can start a 60 second countdown and to prevent people abusing this button, I want to make a log on the screen saying "(player) has started a countdown!) ((player) being the player who started the timer's name.) I don't know how to do this and I can't just do Players.LocalPlayer because it's a normal script not a local one. I have everything else done i just want this now. I don't want it as a local script because I want everyone to see who started the timer. Plz someone help

0
MouseClick's first parameter is the player who clicked, so you can do <player>.Name (<player> is the parameter name) Pupppy44 671 — 3y
0
Are you using a textbutton or a clickdetector? IAmNotTheReal_MePipe 418 — 3y
0
Text button. It then fires on all clients with the name of the person who clicked the button AngryPlaayer 17 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

The first parameter (and probably only) of the MouseClick event is the player who clicked it. Here is a script that will print the player name of the person who clicked it:

local cd = script.Parent --change to where the click detector would be

function onClicked(plr)
   print(plr.Name)
end

cd.MouseClick:Connect(onClicked)
0
It’s not a click detector. Ok since i made this question I’ve changed lots of things. Basically you click the button and on a normal script it fires on all clients making a text label that says “player has started a sword fight” or “player has started a countdown”. Even if i knew how to get the player’s name from the normal script i wouldnt know how to take that name to the local script AngryPlaayer 17 — 3y
Ad

Answer this question