Detecting if a player can be killed

I’d like to first start off with the reason for such a reason; military genre. I’m in one and I need to work on a system to prevent the amount of abuse caused by people on other participants in the game.

note: By abuse I mean random killing

My first thoughts were something similar to how I’d imagine Jailbreak has theirs set up.

  • Detect if a player has done an illegal move
  • Apply this value to a table

This would be for Visitors, you know the innocent people.

What a visitor would need to do to become “bad person” would be entering a restricted area. I was thinking of adding a 10-15 second delay time to add onto when they can be shot at.

Obviously, I’d need to use extreme care while writing code as it can get inefficient and slow really quickly. I’m wondering what my best cause of action would be. (e.g; raycast, magnitude, region3)

I hope I explained this properly and if not I’d be happy to correct any issues.
Any suggestions would be wonderful, thanks!

(writing at 7am syndrome :tired_face:)

You can create a Region3 around every area that’s restricted. When the player is detected to be inside the area you can add a tag to them using CollectionService to mark them as “killable”. You can make it so your guns can only kill people with that tag (check if the hit parts parent i.e the character has the killable tag then do damage). Once they leave the area you can then remove the tag from them.

2 Likes

I’m just not too 100% on Region3 as it can end up eating up memory. I’m not too sure if there are any other ways I can go about it that wouldn’t involve a loop checking each second or something that wouldn’t take up too much memory.

It is unfair to judge the performance of Region3 in a scenario like this, as they become more performance intensive as the size of them grows. (Source)

While Region3’s aren’t inherently expensive performance wise to use, you could get away with using magnitude, however that provides a more “circular” area rather than a rectangular one with Region3, as you’d be checking the magnitude of the character to a central part signifying the middle of the restricted area.

As for your concern about a while loop, there’s really not much more you can do to check where a player is often. A while loop won’t necessary ruin the player’s experience with lag either. If you are really concerned you could just check every second where they are, rather than using Heartbeat or similar.

Chances are if you’re having memory issues in your game you have other problems to address and should probably look at optimising them first, rather than limiting yourself with future methods for features.

Fair enough, thanks for the response!

1 Like

I’ve just thought of an issue I’m going to have with this. Let’s say an exploiter flies over the region and a player kills the exploiter the player will be “warned” for doing nothing wrong. I’m not sure how I can get around this or if you know any other solution