I added the CollisionGroups like this!
local Players = game:GetService("Players")
local PhysicsService = game:GetService("PhysicsService")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
for i, object in ipairs(character:GetDescendants()) do
if object:IsA("BasePart") then
object.CollisionGroup = "Player"
end
end
end)
end)
local ServerStorage = game:GetService("ServerStorage")
local mob = {}
local PhysicsService = game:GetService("PhysicsService")
function mob.Move(mob,map)
local humanoid = mob:WaitForChild("Humanoid")
local waypoints = map.Waypoints
for waypoint=1, #waypoints:GetChildren() do
humanoid:MoveTo(waypoints[waypoint].Position)
humanoid.MoveToFinished:Wait()
end
mob:Destroy()
end
function mob.Spawn(name, quantity, map)
local mobExists = ServerStorage.Mobs:FindFirstChild(name)
if mobExists then
for i=1, quantity do
task.wait(0.5)
local newMob = mobExists:Clone()
newMob.HumanoidRootPart.CFrame = map.Start.CFrame
newMob.Parent = map.Mob
for i, object in ipairs(newMob:GetDescendants()) do
if object:IsA("BasePart") then
object.CollisionGroup = "Mob"
end
end
coroutine.wrap(mob.Move)(newMob, map)
end
else
warn("Requested mob does not exist:",name)
end
end
return mob
But the Player can still collide with the Mob and the Mob can still collide with the Player and the Mob can still collide with another Mob. Why?