Help needed with hiding system

Hello everyone :wave::smiley:
So I’m wondering how I could make a script in a pathfinding NPC that kills people when they aren’t in a locker or closet (yes I got this idea from Doors). I’ve already got the locker, but I think making the HumanoidRootPart very wide isn’t helpful.

1 Like

Put a variable at the player character, that variable to know if the player is hiding or not
If the variable is true the npc can’t follow or kill

So, change the variable to true when he hides, and change to false when isn’t hidding

1 Like

This may not be the best solution but it works as I used the same method on my game.
When the player enters the locker, set the camera inside the locker or wherever you want the player to be looking and teleport them away from the map so the bot has no more vision of them. Or another solution could be what @rtvr56565 said.

Thanks everyone for the help, but I found a successful way because the value thing that @rtvr56565 said went to a horrible script (;_;). So I did it now by adding a ForceField when the player enters the locker and removing it when the player goes out of it.