Auto-suicide?

Someone make something that kills you if you are say below 20 health (like if you’re getting shot, to keep from getting the other person points you kill yourself)

Untested
[lua]
ihatemylife = CreateClientConVar(“emohealth”, “20”, true, false)
if LocalPlayer():Health() < ihatemylife then
LocalPlayer():ConCommand(“kill”)
end
[/lua]

I made so much lol in my pants

Messily coded because I did it in the reply window.

-snip-
Misread

Ok someone fix it plz cuz it don’t work.

it should work, whats the error your getting?

Fixed:
[lua]
local ihatemylife = CreateClientConVar(“emohealth”, 20, true, false)
hook.Add(“Think”, “SuicideHealthCheckThink”, function()
if LocalPlayer():Alive() && LocalPlayer():Health() < ihatemylife:GetInt() then
RunConsoleCommand(“kill”)
end
end)
[/lua]

CreateClientConVar returns a ConVar object, to get the value of it you have to use ConVar.GetString/Int/Float/Bool().

//EDIT:

Oops… yeah, didn’t see that.
Anyway, my code works definitely, I tried it.

FlapJack fixed it and I assume thats the code he used and got the error with.