Make players invincible in other team's spawn room

So when someone teleports (custom teleport with interact key) to another team’s room they die in like 3 seconds. Is there a way to make them invincible in other team’s spawn room? The only way I can think of is custom positions for different maps but is there an easier way to do this?

set recive damage to 0

But then they won’t receive any damage at all even when not in spawn room.

set condition
if player in area then recive 0 dmg if not 100 dmg

I can only set the area to player’s team’s spawn room but I want the player not to receive damage in enemy team’s spawn room.

take the coordinate and set invincible status in it

Ye but I would have to do it for every map. Different cooridantes. I asked if there is easier way.