How do you handle combat logging?

Yo, I want to start a combat log prevention system in my game, and I have a good idea but I’m not sure if it will work.

I was thinking to use a :GetPropertyChangedSignal on every humanoid’s health and then do a FindFirstChild on the creator tag in the humanoid, which I’ve implemented into all of my weapons on every hit. If it’s not nil and exists, then I can mark the player as “In Combat” and then start a while loop, which keeps waiting for let’s say 5 seconds, and run FindFirstChild checks on the creator tag each time. If it’s still there, keep it as in combat, if it’s nil, break the loop and unmark the player.

Is this a good way of doing this? If not, how would you do it?

2 Likes

From the looks of it, I think your way of doing it makes sense.

1 Like

Instead of using a while loop, maybe add a tag to the Player instance of the player that is in combat. And then in the game.players.onPlayerRemoving event you can check if the player who left, has the ‘in combat’ tag, and then do whatever you want to do.

Your way also seems fine, but this way you avoid while loops :slight_smile:

1 Like