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

Make NPC not collide with players?

Asked by 5 years ago

Hey im currently making a walking npc and i really want to know how i disable the cancollide of the player. Everyone in my game is disturbing the movement of the NPC while he is walking. Is there a way that no one can disturb the NPC its movement?

Sincerly Nathan EggService The Netherlands

0
create a collision group greatneil80 2647 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Hello! I found this earlier, its called Collision Filtering Try this maybe? I didn't test it, but I hope this worked. Also if this doesn't work, or no one can answer there is some other articals and stuff around the internet. Hopefully this helps.

01local PhysicsService = game:GetService("PhysicsService")
02npcGroup = "npcGroup"
03PhysicsService:CreateCollisionGroup(npcGroup)
04PhysicsService:CollisionGroupSetCollidable(npcGroup, npcGroup, false)
05local function setCollisionGroupRecursive(object)
06    if object:IsA("BasePart") then
07        PhysicsService:SetPartCollisionGroup(object, npcGroup)
08    end
09    for _, child in ipairs(object:GetChildren()) do
10        setCollisionGroupRecursive(child)
11    end
12end
13npc = workspace.NPC
14setCollisionGroupRecursive(npc)
Ad

Answer this question