Anti teamkill not working properly

I have this anti teamkill script inside of a module script, which returns “true” if you can kill them, and “false” if you can’t kill them. For some reason it only works for some teams, and I do not know why. If anyone could help out that would be greatly appreciated. There are no errors in the console or anything either.

function my_functions.teamkillCheck(player, tryingToKill)
	if player.Team == tryingToKill.Team then
		return false
	end
	
	if player.Team ~= tryingToKill.Team then
		if tryingToKill.Team == game.Teams["Grenadier Guards"] or tryingToKill.Team == game.Teams["Royal Military Police"] or tryingToKill.Team == game.Teams.Headquarters then
			if player.Team == game.Teams["Grenadier Guards"] or player.Team == game.Teams["Royal Military Police"] or player.Team == game.Teams.Headquarters then
				print("Player is friendly")
				return false
			else
				print("Player is not friendly")
				return true
			end
		elseif tryingToKill.Team == game.Teams["The irish Insurgency"] or tryingToKill.Team == game.Teams.Civilians then
			if player.Team == game.Teams["The irish Insurgency"] or player.Team == game.Teams.Civilians then
				print("Player is friendly")
				return false
			else
				print("Player is not friendly")
				return true
			end
		end
	end
end

How about using Team color instead team name or instance?

1 Like

Not too sure if that would make a difference. Logically, it would all be the same.

If you made typo It can be diffrent :confused:

1 Like

I guess I’ll try it then. I’ll let you know if it’s any diferrent.

You could try to print the player team after “if player.Team ~= tryingToKill.Team then” and see if it doesnt match anything in your script