Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can you make a local part for an NPC?

Asked by 5 years ago
Edited 5 years ago

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?

1 answer

Log in to vote
1
Answered by 5 years ago

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.

0
Thank you!! I hadn't heard of collision groups before, and after looking up a tutorial on how they work, I was able implement it. No more players sneaking into NPC houses! OswinFalls 69 — 5y
0
You're welcome! paperbagstudio 28 — 5y
Ad

Answer this question