Allied team script help

Hi, I’m trying to make a system where Government role teams aren’t able to kill one another (Allied teams pretty much) but not merge them into one team. I created a script based off of this devfourm article but the script didn’t work for me in testing. If anyone could help it would be greatly appreciated.

Example of what im going for:
All the government teams cant attack one another, but are able to attack teams outside the circleimage

I put the script below for the anti kill system.
List of teams:
image

local function canHurtVictim(player, victim)
	local playerTeam = player.Team.Name
	local victimTeam = victim.Team.Name
		--Rebel Team Perms
		if (playerTeam == "Soldiers" and victimTeam == "Rebels") or
			(playerTeam == "Rebels" and victimTeam == "Soldiers") or 
		
		    (playerTeam == "Admissions Officers" and victimTeam == "Rebels") or
			(playerTeam == "Rebels" and victimTeam == "Admissions Officers") or 
		
			(playerTeam == "Tourist Control" and victimTeam == "Rebels") or
			(playerTeam == "Rebels" and victimTeam == "Tourist Control") or  
		
			(playerTeam == "Tourist Control" and victimTeam == "Rebels") or
			(playerTeam == "Rebels" and victimTeam == "Tourist Control") or 
		
			(playerTeam == "USGS Employees" and victimTeam == "Rebels") or
			(playerTeam == "Rebels" and victimTeam == "USGS Employees") or
		
			(playerTeam == "USGS Chief Advisor" and victimTeam == "Rebels") or
			(playerTeam == "Rebels" and victimTeam == "USGS Chief Advisor") or not
		
		---USGS Employee Team Perms
		--Tourist Control
			(playerTeam == "USGS Employees" and victimTeam == "Tourist Control") or
			(playerTeam == "Tourist Control" and victimTeam == "USGS Employees") or
		--Soldiers
			(playerTeam == "USGS Employees" and victimTeam == "Soldiers") or
			(playerTeam == "Soldiers" and victimTeam == "USGS Employees") or
		--Admissions Officers
			(playerTeam == "USGS Employees" and victimTeam == "Admissions Officers") or
			(playerTeam == "Admissions Officers" and victimTeam == "USGS Employees") or 
		--Chief Advisor
			(playerTeam == "USGS Employees" and victimTeam == "USGS Chief Advisor") or
			(playerTeam == "USGS Chief Advisor" and victimTeam == "USGS Employees") or
			
			---Tourist Control Team Perms 
			--Soldiers
			(playerTeam == "Tourist Control" and victimTeam == "Soldiers") or
			(playerTeam == "Soldiers" and victimTeam == "Tourist Control") or
			--Admissions Officers
			(playerTeam == "Tourist Control" and victimTeam == "Admissions Officers") or
			(playerTeam == "Admissions Officers" and victimTeam == "Tourist Control") or 
			--Chief Advisor
			(playerTeam == "Tourist Control" and victimTeam == "USGS Chief Advisor") or
			(playerTeam == "USGS Chief Advisor" and victimTeam == "Tourist Control") or
			
			---Admissions Officer Team Perms then
			--Soldiers
			(playerTeam == "Admissions Officers" and victimTeam == "Soldiers") or
			(playerTeam == "Soldiers" and victimTeam == "Admissions Officers") or
			--Tourist Control
			(playerTeam == "Tourist Control" and victimTeam == "Admissions Officers") or
			(playerTeam == "Admissions Officers" and victimTeam == "Tourist Control") or 
			--Chief Advisor
			(playerTeam == "Admissions Officers" and victimTeam == "USGS Chief Advisor") or
			(playerTeam == "USGS Chief Advisor" and victimTeam == "Admissions Officers") or
			
			---Soldier Team Perms
			--Soldiers
			(playerTeam == "Admissions Officers" and victimTeam == "Soldiers") or
			(playerTeam == "Soldiers" and victimTeam == "Admissions Officers") or
			--Tourist Control
			(playerTeam == "Tourist Control" and victimTeam == "Soldiers") or
			(playerTeam == "Soldiers" and victimTeam == "Tourist Control") or 
			--Chief Advisor
			(playerTeam == "Soldiers" and victimTeam == "USGS Chief Advisor") or
			(playerTeam == "USGS Chief Advisor" and victimTeam == "Soldiers") then
		
		
	end
end
2 Likes

So, any team in the green circle can hurt each other, and government teams can hurt the ones in the circle, and teams in the circle can hurt the government, BUT the governments can hit each other?

What about this?
(Government teams can’t attack each other)
(Teams in circle can attack each other)
(Teams in circle and governments can attack each other)

function isInGovernmentTeam(player)
    local teamName = player.Team.Name
    return teamName == "Government 1" or teamName == "Government 2" -- Replace with your own
end

function canHurtVictim(player, victim)
    if isInGovernmentTeam(player) and isInGovernmentTeam(victim) then
        return false -- Governments can't hurt each other
    end
    return true
end

No, I meant that the teams in the circle are the government ones and can not harm each other, but they can still fight with the two teams outside of the circle

Ok,

function inNormalTeam(player)
    local teamName = player.Team.Name
    return teamName == "Rebels" or teamName == "Civilian" -- Replace with your own
end

function canHurtVictim(player, victim)
    return inNormalTeam(player) or inNormalTeam(victim)
end

Unfortunately it didn’t work out as I could still kill other teams in testing so I’ll have to figure something out. Thanks for the help though. If anyone else has any ideas feel free to post them.

Just to clarify, Government teams can’t hurt eachother, rebels and civilians can hurt eachother, and civilians+rebels and governments can hurt each other?

yeah thats the plan for my game

Try printing out the result of canHurtVictim

local alliedTeams={
	["Blue"]=true
}
function checkTeams(teamName)
	if alliedTeams[teamName] then
		return true
	end
end

if checkTeams("Blue") then
	-- dont damage
else
	-- damage
end