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)
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.
You already have it? You have game.Players.LocalPlayer.
You need to use remote events for the leaderstats.