Any command to kill ply on server?

Hi, I have made a soda SENT that takes 5 health from you each time you drik one, but when you have 0 halth, you dont die, the function is running in init.lua, so how can I kill the player if he/she has less then 1 HP?

[lua]hook.Add(“Think”,“fu”, function() if LocalPlayer():Health() <= 0 then LocalPlayer():Kill() end end)[/lua]

Or you could just add that if statement to the code that takes the health away. But an even better way would be to use **[Entity.TakeDamage](**.

It’s was an quick example, stop being an ass, doesn’t take him 10 minutes to find it him self.

lolz more boxes to care about /care.

You can’t kill LocalPlayer anyway without using RunConsoleCommand.

I’m not being an ass. He asked for help so I gave him decent help, better than your feeble attempt.


You are constantly giving bad advice/code that doesn’t work. You need to put more effort into it, or don’t post at all.

Dumb yes you can it’s called ply:Kill and its server side and shut up GayMaker.

Yes, but LocalPlayer is clientside.

You don’t know much about Lua scripting do you Cubar?
Also, don’t insult MakeR, he has achieved more than you in life.

I know more lua then you faggot.

Yes i do know i think everyone should know retard.

Ok ok no need to flame anymore close the thread, no one cares.

(User was banned for this post ("Flaming" - SteveUK))

Agreed, or polite/nice/friendly? Agree. (at the first part)

So, any code that is workin?

You basically need to replace your code that does the damage with the TakeDamage function.

I’m guessing that your code looks somewhat like this:
[lua]function ENT:Use(activator, caller)
if activator and activator:IsPlayer() then
activator:SetHealth(activator:Health() - 5)

You need to do something like this instead:
[lua]function ENT:Use(activator, caller)
if activator and activator:IsPlayer() then
activator:TakeDamage(5, self)

Hehe, you can read minds what? Thank you. Rating useful.

No he just guessed…

Way to be an ass.

I always thought of Cubar as a nice guy, but now he’s the resident troll…

He’s like a hormonal pkowner.

Thanks for reminding me of him. Ugh.

Why did you have an orgasm at the end of that sentence? :3:

I don’t see why you’ve ever seen him as a nice guy. Almost all his posts aren’t helpful at all, he’s trolling half of the time, and has no knowledge of Lua at all. I mean, would you honestly try to kill LocalPlayer()?