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

How Do I Get A Player Name From A TextButton?

Im trying to make it so when a button is pressed the leaderstats go down. All I need is the player that clicked the button

script.Parent.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer

--leaderstats
game.Workspace.Camera.Walls.World1wall:Destroy()
	game.StarterGui.WallScripts.Wall1:Destroy()
	script.Parent.Parent.Parent:Destroy()
end)

2 answers

✓ Accepted answer

If you want to find the player's name that clicks the TextButton then you should use LocalScript and make sure that variable local plr is above the function which is script.Parent.MouseButton1Click:Connect(function().

Since you only ask how to find the player's name that clicks the TextButton and not a script to make leaderstats go down so here is the code.

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	print(plr.Name) -- replace this with function you want.
end)

If this answer helped you then please accept the answer.

1 comment

0

at least i write detailed version of this. But i am still too slow.

You already have it? You have game.Players.LocalPlayer.

You need to use remote events for the leaderstats.

1 comment

0

oh shoot thats the wrong script but yea I guess Remote Events will work

This discussion is preserved as it was. New answers, comments, and votes are closed.