local start = workspace.StartPoint
local endpoint = workspace.EndPoint
local PathfindingService = game:GetService("PathfindingService")
local ServerStorage = game:GetService("ServerStorage")
local rig = ServerStorage.Rig
local spawnCD = 3
local mobSpeed = 8
local debounce = {}
local function SpawnMob()
local unit = rig:Clone()
unit.PrimaryPart = unit:WaitForChild("HumanoidRootPart")
unit:SetPrimaryPartCFrame(start.CFrame)
unit.Parent = workspace
unit.PrimaryPart:SetNetworkOwner(nil)
unit.Name = "Rig"
local humanoid = unit:FindFirstChild("Humanoid")
humanoid.WalkSpeed = mobSpeed
local hrp = unit.PrimaryPart
local path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
AgentCanClimb = true
})
path:ComputeAsync(hrp.Position, endpoint.Position)
if path.Status == Enum.PathStatus.Success then
local waypoints = path:GetWaypoints()
for _, waypoint in pairs(waypoints) do
if unit and unit.Parent and humanoid and humanoid.Parent then
humanoid:MoveTo(waypoint.Position)
else
break
end
end
end
end
endpoint.Touched:Connect(function(hit)
local mob = hit and hit.Parent
if mob and mob:IsA("Model") and mob.Name == "Rig" and not debounce[mob] then
debounce[mob] = true
mob:Destroy()
debounce[mob] = nil
end
end)
task.spawn(function()
while true do
SpawnMob()
task.wait(spawnCD)
end
end)
how to make it that players cant touch, push, block the mobs?
i tried to cancollide false all baseparts when clone but didnt work