Making players able to walk through a zombie humanoid

I have got a zombie from the marketplace, but I can’t figure out how to make it so that players cant collide with it, and also I can’t figure out how to make it so that the zombie can walk through walls.

collisiongroup is ur ally
–characters–

1 Like

Hi, I tried collision groups but the zombies still collided with everything (parts and players)

have u put the right part in group? some parts of the zombie dont need CanCollide true, only the humanoidrootpart, and put that humanoidrootpart into collision group

1 Like

Just tried that and still no luck

Here is the zombie if that helps:
image

local Workspace = game:GetService("Workspace")

local function MakeZombiesNonCollidable(zombie)
    for _, part in ipairs(zombie:GetDescendants()) do
        if part:IsA("BasePart") then
            local collisionGroup = Instance.new("CollisionGroupId")
            collisionGroup.Value = 1
            part.CustomPhysicalProperties = PhysicalProperties.new(0, 0.3, 0.5)
            part:SetAttribute("CollisionGroupId", collisionGroup.Value)
        end
    end
end

local function OnZombieAdded(zombie)
    if zombie:IsA("Model") and zombie:FindFirstChild("Humanoid") then
        MakeZombiesNonCollidable(zombie)
    end
end

Workspace.DescendantAdded:Connect(OnZombieAdded)

local function SetupPlayerCollisionGroups(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
    local collisionGroup = Instance.new("CollisionGroupId")
    collisionGroup.Value = 2
    humanoidRootPart.CustomPhysicalProperties = PhysicalProperties.new(0, 0.3, 0.5)
    humanoidRootPart:SetAttribute("CollisionGroupId", collisionGroup.Value)
end

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(SetupPlayerCollisionGroups)
for _, player in ipairs(Players:GetPlayers()) do
    if player.Character then
        SetupPlayerCollisionGroups(player)
    else
        player.CharacterAdded:Connect(SetupPlayerCollisionGroups)
    end
end

local function ApplyCollisionGroups()
    local collisionGroupsService = game:GetService("CollisionGroups")
    collisionGroupsService:SetCollisionGroup(1, "Zombies")
    collisionGroupsService:SetCollisionGroup(2, "Players")
    collisionGroupsService:CollisionGroupsAreCollidable(1, 2, false)
end

ApplyCollisionGroups()
2 Likes

Hi thank you very much, I ran this code and got this error:
‘Unable to create an Instance of type “CollisionGroupId”’
Sorry i’m quite bad at scripting so not sure whats wrong. I put the code in server script, is that right? Or should I put it in a local script