Team() == (Insert team here) isn't working properly?

Note - There may be a way to do this easier, but i am new to lua so try not to give me a hard time =S.

Im making a fretta game, and i am trying to make it so when you kill someone on the opposite team, you switch to there team and they switch to yours.

The problem im having isnt an error, it just seems to not be working/reading the code.

function GM:DoPlayerDeath( ply, attacker, dmginfo )

	self.BaseClass:DoPlayerDeath( ply, attacker, dmginfo )
		if (ply:Team() == TEAM_TOP && attacker:Team() == TEAM_BOTTOM) then 

The “Hello” doesn’t print and i stay on the same team.

I have also tried writing over PlayerDeath but that also didn’t seem to work.

I also wrote a function, saved it as a console command and tried to run it one the player died, but that didn’t work either.

I figured i needed a team.GetPlayers or something, but i wasn’t sure how to fit that in with my code.

Any help appreciated.

You’re setting their player’s team to bottom right before checking if it’s top…



I can’t believe i didn’t see that. That makes me feel like an idiot.

One second ill go try it.

EDIT- Ok that worked, but now im getting team = nil value.

I figured out it was because of the attacker apparently can be defined as a team, i thought attacker was the killer?

Am i wrong? Is there another way to find the person that killed them?

DOUBLE EDIT - I was dying by an entity, i forgot to ad IsPlayer, my bad.

Fixed now! Lock/whatever please.