local Kill = script.Parent function onClicked (MouseButton1Down) local Player = game.StarterGui.TextBox:FindFirstChild("Humanoid") if (Player ~=nil) then do Player.Health = 0 end end TextBox.Touched:connect(onClicked)
Before anything, you would not use a TextBox for this, but rather use a TextButton. Using a LocalScript inside the TextButton, the code would look a bit like this:
Player = game.Players.LocalPlayer Character = Player.Character KillButton = script.Parent KillButton.MouseButton1Click:connect(function() local Humanoid = Character:FindFirstChild("Humanoid") if (Humanoid) then Character.Humanoid:TakeDamage(Character.Humanoid.MaxHealth) end end)
Where is TextBox defined? Did you mean to make TextBox Kill?
If TextBox(or Kill) is the kill button, you need to make it MouseButton1Click.
Also, you put if(Player) then do,
I'm guessing that was a typo.
Possible Fix:
local KillButton=script.Parent; function onClicked() local Player = game.StarterGui.TextBox:FindFirstChild("Humanoid"); if (Player) then Player.Health=0; end; end; KillButton.MouseButton1Click:connect(onClicked);