Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How to detect the player's name when a gui has been clicked?

Asked by 3 days ago

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!!

2 answers

Log in to vote
0
Answered by 3 days ago

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!

Ad
Log in to vote
0
Answered by 3 days ago

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'.

Answer this question