How do I make a script that damages a player with a cooldown every few seconds?

For a system like this, i’d argue that is probably better to use a module like ZonePlus. You can find this here ZonePlus v3.2.0 | Construct dynamic zones and effectively determine players and parts within their boundaries