Hello,
I want my NPC to be able to go through the staff door, but the players shouldn’t be able to. My staff door is collidable, so I wrote this script:
local physics = game:GetService('PhysicsService')
local collisionGroup = physics:CreateCollisionGroup('group')
local npsGroup = physics:CreateCollisionGroup('npcs')
physics:CollisionGroupSetCollidable('npcs','group',false)
local function main()
for _, mainPart in pairs(workspace.Teacher:GetChildren()) do
if mainPart:IsA('BasePart') then
physics:SetPartCollisionGroup(mainPart,'npcs')
end
end
for _, doorPart in pairs(workspace.StaffDoor:GetChildren()) do
if doorPart:IsA('BasePart') then
physics:SetPartCollisionGroup(doorPart,'group')
end
end
end
wait(math.random(3,5))
main()
However, my NPC cannot go through the door.
I appreciate help!