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 4 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 — 4y

1 answer

Log in to vote
0
Answered by 4 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.

local PhysicsService = game:GetService("PhysicsService")
npcGroup = "npcGroup"
PhysicsService:CreateCollisionGroup(npcGroup) 
PhysicsService:CollisionGroupSetCollidable(npcGroup, npcGroup, false) 
local function setCollisionGroupRecursive(object) 
    if object:IsA("BasePart") then 
        PhysicsService:SetPartCollisionGroup(object, npcGroup) 
    end
    for _, child in ipairs(object:GetChildren()) do 
        setCollisionGroupRecursive(child)
    end
end
npc = workspace.NPC
setCollisionGroupRecursive(npc)
Ad

Answer this question