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

How to turn off collisions for enemies?

Asked by 3 years ago

im trying to make a script that turns off collisions for npcs so that they dont collide into one another, but its not working:

the script is a server script btw

local PhysicsService = game:GetService("PhysicsService")
local NPCGroup = PhysicsService:CreateCollisionGroup("NPCS")

PhysicsService:CollisionGroupSetCollidable("NPCS", "NPCS", false)

while true do
    wait(0.1)
    for i, v in pairs(workspace:GetChildren()) do
        if v:IsA("BasePart") and v.Parent:FindFirstChildOfClass("Humanoid") then
            PhysicsService:SetPartCollisionGroup(v, "NPCS")
        end
    end
end

Answer this question