I have look at it many times and I can't figure out what's wrong, I have NPC's that walk around and I don't want collision with other NPS's or players
Script code:
local phys = game:GetService("PhysicsService")
local npcGroup = "NPC"
local plrg = "Player"
phys:CreateCollisionGroup(npcGroup)
phys:CreateCollisionGroup(plrg)
phys:CollisionGroupSetCollidable(plrg, npcGroup, false)
phys:CollisionGroupSetCollidable(npcGroup, npcGroup, false)
phys:CollisionGroupSetCollidable(plrg, plrg, false)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
for i =1,#char:GetChildren() do
if char:GetChildren()[i]:IsA("Part") or char:GetChildren()[i]:IsA("MeshPart") then
phys:SetPartCollisionGroup(char:GetChildren()[i],plrg)
end
end
end)
end)
NPC Code:
local phys = game:GetService("PhysicsService")
for i=1,#script.Parent:GetChildren() do
if script.Parent:GetChildren()[i]:IsA("Part") then
phys:SetPartCollisionGroup(script.Parent:GetChildren()[i],"NPC")
end
end
