I've added two collision groups, one for the mobs, and one for the players, and set them to be unable to collide. This works like 80% of the time, but this happens sometimes: https://gyazo.com/e883406a2fb7631225257f34e485e1c7
I've tried manually making the collision groups and setting all of the properties, parts, etc beforehand, and I've also tried setting them in a script. Right now, I have it in a script, and I was wondering what was causing this.
Server Script in ServerScriptService:
local PS = game:GetService("PhysicsService")
PS:CreateCollisionGroup("players")
PS:CreateCollisionGroup("mobs")
PS:CollisionGroupSetCollidable("players","mobs",false) PS:CollisionGroupSetCollidable("mobs","mobs", false)
function NoCollide(model, group)
for i,v in pairs(model:GetChildren()) do
if v:IsA"BasePart" or v:IsA"UnionOperation" then
PS:SetPartCollisionGroup(v, group)
end
end
end
game.Workspace.Mobs.Sloobers.ChildAdded:Connect(function(Sloober) --Sloobers and Mobs are both folders
NoCollide(Sloober, "mobs")
end)
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(c)
NoCollide(c, "players")
c.ChildAdded:Connect(function(child)
NoCollide(child,"players")
end)
end)
end)
while wait(3) do --Spawning
if #workspace.Mobs.Sloobers:GetChildren() < 15 then
local Sloober = game.ServerStorage.Mobs.Sloober:Clone()
Sloober:WaitForChild("HumanoidRootPart").Position = Vector3.new(math.random(0,30), 0.25, math.random(0, 30))
Sloober.Parent = workspace.Mobs.Sloobers
wait(3)
end
end
To confirm that the groups are correct, I clicked on the mobs and player in the collision group window found in "Model", and the parts corresponded perfectly, meaning that they should work...
