In my town game, I have NPCs that wander a certain area during the day, and then go to their homes at night. I'd like for them to be able to go through a door but not let anyone else through.
Currently my system is a touchedbased system with the door that turns off CanCollide when touched by the NPC. I have the wait() as low as possible to still allow the NPC through, but a really dedicated player could still get through if they waited for the NPC and tried to run through the door at the exact same moment.
I've made other doors before that only allow certain players through by using a local script, but that wouldn't be possible with an NPC, correct? Is there a way to make something local for an NPC model or another way to allow only the NPC through?
Ok, so assuming that the door doesn't open and the npcs literally walk through the door, use collision groups. If you set it where a npc can pass through but a player cannot for the time being, then it will be solved.
But, if the door does open, then make it were a transparent part will spawn that blocks players from entering the house, doing the same thing (collision group to collide with players but not npcs).
That should fix the problem.