How to catch combat loggers/make an incombat state?

I looked for posts on the devforum and youtube but nothing really helped, but I am trying to put the player inside of an indanger state if they are attacked (likely just take damage), and also punish them for combat logging

Not exactly sure how to do this, I considered making a boolvalue inside of the player and had it set to true when they took damage, and wait a certain amount of time then set it to false, and if they got attacked during the time it would restart the timer again

my issue with this was a hacker could simply toggle the value on and off, also, I don’t know how to detect if they leave

1 Like

The server should be the one that is checking the combat state. If a player enters combat, the server sets the combat log bool value to true. By doing this, exploiters can’t change the combat log bool value to false and circumvent the system, since most actions done on the client don’t replicate back to the server.

There is an event called PlayerRemoving which I believe should be what you’re looking for if you’re trying to find a way to detect when a player leaves the game. I believe you should be able to use it in some way to check if a player is in combat when they leave and if so, save that information for when they join back in.

I’m not good enough at scripting to give an example, but I hope this should be enough to get you closer to where you need to be.