Point system breaking?

Hi, I made a point system, and it breaks randomly in the middle of playing, like in the beginning it works perfectly, then it stops working =/
its shared

[lua]
if (SERVER) then
hook.Add ( “PlayerDeath”, “killcredit”, function ( victim, weapon, killer )
if killer:Team() == victim:Team() then
for k, v in pairs(player.GetAll()) do
v:EmitSound( “unreal/teamkiller.wav”, 100, 100 )
end
killer:TakeMoney( 20 )
killer:PrintMessage( HUD_PRINTTALK, "You lost 20 points for team killing " … victim:Nick() … “! You now have " … killer:GetMoney() … " points!”)
else
if victim:LastHitGroup() == HITGROUP_HEAD or victim:LastHitGroup() == 1 or victim:LastHitGroup() == HEAD then
killer:AddMoney( 50 )
killer:PrintMessage( HUD_PRINTCENTER, “HEADSHOT!”)
killer:PrintMessage( HUD_PRINTTALK, “You gained 50 points for getting a headshot! You now have " … killer:GetMoney() … " points!”)
for k, v in pairs(player.GetAll()) do
v:EmitSound( “unreal/headshot.wav”, 100, 100 )
end
else
killer:AddMoney( 10 )
killer:PrintMessage( HUD_PRINTTALK, "You gained 10 points for killing " … victim:Nick() … “! You now have " … killer:GetMoney() … " points!”)
end
end
end )
end
[/lua]

try to surround it with :


if (victim:IsValid() and victim:IsPlayer() and killer:IsValid() and killer:IsPlayer()) then

Why would that be the problem if the only thing your killing is players, just wondering

I tested it just a while ago without using slay3r36’s suggestion, and it didn’t break, and I did everything, I team killed players on both teams, killed players on both teams, headshot players on both teams, I disconnected and did it all again, and it didn’t break… if this is random I’m gonna be really pissed lol

When does it break and can you provide any errors?

There were no errors, it just stopped giving notifications and chat and didn’t change the player’s points when they got kills n everything, so far I’ve seen this happen twice, it was random. Maybe the player’s points were negative and it didn’t like it or something, I dunno.

…However I do remember using the ULX Trainfuck addon before, which is a train that runs over people, just for kicks lol, maybe that broke it somehow =S

If you have something working then something must occur for it to break.

e.g. When the train killed them it broke.
e.g. When the player disconnected it broke.

We need to know what occurance it broke on.

I dunno it just breaks randomly =S like ulx’s admin menu