Why is my code not working?

So there’s this weapon called the ‘golden gun’ for The TTT gamemode in Gmod.

The gun essentially kills traitors and leaves innocents unharmed. The problem is people in the server I manage have said this is too cheap. I agree with them so I wanted to make it so that if a detective shoots an innocent with this gun then it should kill them (The detective holding the gun.) Here is the code for determining whether or not to kill the player in the gun.
[lua]
function CheckTTTTarget(att, path, dmginfo)
if (SERVER) then
local hitent = path.Entity
if (hitent:IsPlayer() && hitent:IsValid()) then
if (!hitent:IsTraitor() && !att:IsTraitor()) then
/local dmginfo = DamageInfo()
dmginfo:SetDamage( 1000 )
dmginfo:SetDamageType( DMG_BULLET )
dmginfo:SetAttacker( att )
dmginfo:SetDamageForce( Vector( 0, 0, 100 ) )
hitent:TakeDamageInfo( dmginfo )
/
return {damage=false}
end

	else
		return {damage=false}
	end
end

end
[/lua]
This code works, now what I tried doing was adding RunConsoleCommand( “kill” ) to the part right after the damage=false end. It did not work. I also tried using return {ply:kill()} as well, which also didn’t work. I’m positive if I can figure this out it will help me know a bit more about lua, I really want to figure it out, can anyone tell me what I’m doing wrong?

Indescriptive thread title.
Posting code outside


[lua] tags.

That's what you are doing wrong.

Fixed.

Look in console. It might be saying something like…


FCVAR_SERVER_CAN_EXECUTE prevented server running command: kill

If that’s the case, then try something like this…


ply:SendLua("LocalPlayer():ConCommand('kill')")

in place of


RunConsoleCommand("kill")

I don’t know if this is the best way to do it, but when I tried making chat commands for actions and suicide, it kept blocking the player from running them, and this code fixed the problem.

Don’t use RunConsoleCommand kill, because an alias can stop your code from working.

use ENTITY:Kill( ), or a damage hook such as entity take damage, or damage info, then pass the appropriate data into those to ensure damage is given.