How to make players not damage each other in different teams

Hello, I know how to do an anti-team kill, something like this:

local hitmodel = players:GetPlayerFromCharacter(hit.Parent)

if hitmodel and (player.Team ~= hitmodel.Team) then

But the problem is that I have several teams that should not cause damage to each other.
Currently, if a player from the MTF team shoots a second player from the same team, nothing happens.
But if an MTF player shoots a player from the Guards team, that player will take damage, but I don’t want this, I want the MTF team not to cause damage to the Guards team.
I don’t have ideas.

local teamlist = {["Guards"]=1, ["Default"]=1, ["Players"]=2} --Guard and Default in one team, Players in another

local hitmodel = players:GetPlayerFromCharacter(hit.Parent)
if hitmodel and teamlist[player.Team.Name]~=teamlist[hitmodel.Team.Name] then --We take damage if the team numbers are different

Thank you, this helped alot.
√900 chars

I got one question. What if i have one special team that can’t be damage from every team in teamlist?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.