I have a secret in my game where an npc comes out of a door, however I don't want the player to be able to walk into that door when it's open. I tried making an invisible wall and setting it's CanCollide to true in a local script, but the npc can't walk through it then either. Is there any way to achieve this?
COMMUNITY QUESTION
How would I make a NPC be able to walk through a certain part?
1 answer
I believe PhysicsService can work. Here is an example where two parts (that can collide) can be made to not collide while still colliding with anything else.
local PhysicsService = game:GetService('PhysicsService')
-- you can name the groups anything you want
local Group1 = PhysicsService:CreateCollisionGroup('Group1')
local Group2 = PhysicsService:CreateCollisionGroup('Group2')
-- true to make it so they can collide
PhysicsService:CollisionGroupSetCollidable('Group1', 'Group2', false)
-- some parts
local Part1 = Instance.new('Part')
local Part2 = Instance.new('Part')
Part1.Parent = workspace
Part2.Parent = workspace
-- set the collision groups of the parts
PhysicsService:SetPartCollisionGroup(Part1, 'Group1')
PhysicsService:SetPartCollisionGroup(Part2, 'Group2')
1 comment
0
Yeah I just figured that out. Thanks though.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
use the parameter of the Touched event
How would that work?