Use tags (but one script)
Well, your tag might not be using the Unity tag system. But you absolutely do not want to use different scripts! You'd be copying the entire class and changing one line. As soon as you find yourself duplicating code in order to make a simple behavioral differentiation, you should realize that your design is broken.
For example, if you wanted to move from 2 teams to 3, how much code would you have to change? If the answer is "all the work you did to make 2 teams all over again" then you did everything wrong. All you should have to do is add a single entry in a single place (e.g. adding the new team name to
EnumTeams or similar) and everything else handles it automatically. You might never reach that ideal, but in thinking about it you can identify "oh, if I do this, I'll have to do a lot of work again in the future if I wanted to add a third team, is there a better way I can do it instead?"
What you should do instead is to make that "one line change" some sort of variable factor. Either the script has a public field that says "I am on blue team" (and then your random targeting logic looks at that field, and if the target's team is the same as self's team, ignore that target and find a new one) or you adjust the architecture to introduce a new class that defines the team and how targeting logic should handle teams.
What I mean by a new class here is some sort of "team" concept that allows your AI to identify what team it's on, and what teams its team is allied with (if you had 8 teams and wanted to have alliances, now you have teams of teams, how much rework would you have to do again!?). You might even want to have the "find me a target" code here, so that you can choose randomly from a list of only valid targets (eg. writing a function that automatically finds all living players that are NOT on the current team or its allied teams, and selecting a random one from that list, avoiding having to write a loop that keeps randomly selecting until a valid object is found).