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 ) ply:CreateRagdoll() ply:AddDeaths(1) ply:Flashlight(false) ply:SetTeam(TEAM_BOTTOM) if (ply:Team() == TEAM_TOP && attacker:Team() == TEAM_BOTTOM) then attacker:KillSilent() print("hello") attacker:SetTeam(TEAM_TOP) end end
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.