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

How Do I Get A Player Name From A TextButton?

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

0
at least i write detailed version of this. But i am still too slow. Somone_exe 224 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

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

You need to use remote events for the leaderstats.

0
oh shoot thats the wrong script but yea I guess Remote Events will work thenormalelevator32 26 — 4y

Answer this question