How do I make a continuous damage script?

I want to make a script that damages you continuously, even when standing still.

This is a perfect job for custom components. Too bad we don’t have that technology yet…

Anyways to achieve what you want in pseudo code (I’m on my phone so I can’t write it out), all you need to do is the following:

  1. Use the Tag service and add a tag for when you want someone’s continuous damage mode to start
  2. Use attributes to encode how long you want the debuff to last, how often they should take damage, and how much damage they should take if they do take damage (assuming that all three aren’t constant across all players)
  3. In an update loop, find people with the “continuous damage” tag
  4. Check if the tagged people are in a luau table that also stores how long it’s been since that person took damage and how long they’ve had the continuous damage tag. If they aren’t, damage them immediately by changing their .Health or by using :TakeDamage if you think you need to keep track of the fact that the person died due to continuous damage
  5. Increment both the time from last damage number and the time spent taking continuous damage number by dt (the variable that gets passed into update loops every time they run)
  6. If the time since last damage number is equal to or bigger than the time it’s supposed to take to take continuous damage, then make them take damage and reset the time since last damage to 0
  7. If the time spent taking continuous damage number is bigger than the max time they are allowed to take continuous damage, then use the tag service to remove the continuous damage tag and remove them from the luau table
  8. Steps 4-7 should be in a for loop repeating for every person found in step 3