What is wrong with this script? I want it to kill the player who clicks it. I put this on a script inside of the click detector.
script.Parent.MouseClick:Connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then hit.Parent:FindFirstChild('Humanoid').Health = 0 end end)
MouseClick passes the player that clicks it, not a part. You'll want to use hit.Character.Humanoid, and probably rename hit to player to avoid confusion later down the line.
Im not 100% sure, but i believe hit would be a child of the player, not the character, try script.Parent.MouseClick:Connect(function(hit) 2 if hit.Parent.Character:FindFirstChild('Humanoid') then 3 hit.Parent.Character:FindFirstChild('Humanoid').Health = 0 4 end 5 end)