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

How do you find a player if you type there name in an textbox?

Asked by 6 years ago

Hi so I just cant get this script to get working I been experimenting around with it and still its not working I would just like to know how to it the correct way If you are confused with the problem im asking go ahead and comment to explain it more clearly Im not a great explainer so sorry but here is the script~~~~~~~~~~~~~~~~~ if script.Parent.Text:FindFirstChild("Humanoid") then game.Players.LocalPlayer.Character.Humanoid.Health = 0 ~~~~~~~~~~~~~~~~~ dont mind the capital mistakes thanks I hope you guys could help me on this - activatesenju

1 answer

Log in to vote
0
Answered by
Nowaha 459 Moderation Voter
6 years ago
if script.Parent.Text == game.Players.LocalPlayer.Name then 
    game.Players.LocalPlayer.Character.Humanoid.Health = 0
end

Explaination:

You used _:FindFirstChild(<name>), which searches if the object that you are referencing contains something with the name *<name>*. So this means that you were checking if the script.Parent contained a object named "Humanoid". This doesn't check the text of the textbox. To check the text you use if _.Text = <text> then. In this case you would need to check if the script.Parent.Text = game.Players.LocalPlayer.Name.

Please read the articles below to find out more about the difference.

http://wiki.roblox.com/index.php?title=API:Class/Instance/FindFirstChild

http://wiki.roblox.com/index.php?title=API:Class/TextBox/Text

0
I wouldnt do that. Use if game.Players:FindFirstChild(script.Parent.Text) then PyccknnXakep 1225 — 6y
0
He is clearly using localplayer in his example, so am I in my script. Nowaha 459 — 6y
0
I would check the workspace and game.Players for an object named script.Parent.Text. That's just as a precaution. AstrealDev 728 — 6y
0
I would have made an short and simple autofill system in case the player's name is long, but you guys can do whatever you want. hiimgoodpack 2009 — 6y
0
Well im not only writing the localplayers name but I mean like all the players and if you write a specific players name in the server then they lose their life activatesenju 2 — 6y
Ad

Answer this question