Help implementing the new CollisonGroup to my script

Please help me implement this new CollisonGroup to my script I am currently using the old one and I’m new to coding


Here is my code

local PhysicsService = game:GetService("PhysicsService") -- collison group part
local ServerStorage = game:GetService("ServerStorage")
local mob = {}
local map = workspace.Grassland

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
					PhysicsService:SetPartCollisionGroup(object, "Mob") -- collison group part
				end
			end

			coroutine.wrap(mob.Move)(newMob, map)
		end
	else
		warn("Requested mob does not exist:", name)
	end
end

return mob
1 Like

Using this documentation article and clicking the “Scripting” tab, you can see a sample of how to:

  1. Register your collision groups which you have to do before even setting the collision group for any BasePart, then
  2. Setting your collision groups to collide/not collide as indicated by the boolean, and
  3. Simply setting the property CollisionGroup of the BasePart to either of the group names you registered as appropriate.
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.