execute as @s[tag=team:red] at @s run damage @e[r=40,tag=!iframes,tag=!team:red] 300 override entity @s
execute as @s[tag=team:blue] at @s run damage @e[r=40,tag=!iframes,tag=!team:blue] 300 override entity @s
execute as @s[tag=team:yellow] at @s run damage @e[r=40,tag=!iframes,tag=!team:yellow] 300 override entity @s
execute as @s[tag=!team:red,tag=!team:blue,tag=!team:yellow] at @s run damage @e[r=40,tag=!iframes] 300 override entity @s
tag @s remove iframes