Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I want the text in the textbox to be a name, help?

this is the script, you will know what i mean...

script.Parent.MouseButton1Down:Connect(function()
    local TheName = script.Parent.Parent.TextBox.Text
    game.Workspace.TheName.Humanoid.Health = -1
end)

basically “TheName” should = to textbox text, so it would be... [game.Workspace.(TextBoxText).Humanoid.Health = -1] and textbox text should be a player name e.g. BestCreativeBoy, GameStealerKid etc

2 comments

0

Please provide more details on what the script is supposed to work and what isyour issue

0

you're trying to reduce health from a text. you need the player's character , then the humanoid and then reduce it's health. the name you can get from the player or even the character

1 answer

✓ Accepted answer

I assume that you want to decrease the Health of the player, whose name is in the TextBox. For this, we will be using FindFirstChild.

script.Parent.MouseButton1Down:Connect(function()
	local TheName = script.Parent.Parent.TextBox.Text

	if workspace:FindFirstChild(TheName) and workspace:FindFirstChild(TheName):IsA("Model") and game.Players:FindFirstChild(TheName) then -- Checks whether the text of the textbox exists in the workspace and also, if it is a model, bcz all the Humanoids models' of the players are in a model of thier name. It also checks whether, the text is a player name or not

		local playerName = workspace:FindFirstChild(TheName)
		local hum = playerName:FindFirstChild("Humanoid")
		hum.Health = -1 -- If you are trying to kill the player
	--	hum.Health = hum.Health - 1 [If you want to decrease 1 health of the player]
	end
end)

Lemme know if it helps!

1 comment

0

i will try on friday, thx for the help. Now i understand why it doesn’t work, ty again

This discussion is preserved as it was. New answers, comments, and votes are closed.