I wanted to know whether it is possible to detect the name of the player after he/she clicked on a text button. The player will die when the gui he clicked is wrong so i want to detect what he/she pressed. Thanks in advance!!
✓ ANSWER ACCEPTED
How to detect the player's name when a gui has been clicked?
2 answers
✓ Accepted answer
Since you have to manage UI on the client, you can easily just get the local player using game:GetService("Players").LocalPlayer, and the name is just LocalPlayer.Name. Hope this helped!
Hopefully, this is what you were looking for:
Insert a LocalScript in the TextButton that kills the player, and add the following:
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character.Humanoid.Health = 0
end)
To find the player, you simply use 'game.Players.LocalPlayer'.
This discussion is preserved as it was. New answers, comments, and votes are closed.
