wait(10) local spawnTime = 5 -- the time in seconds local spawnRate = 1 -- per spawn time local pS = game:GetService("PhysicsService") pS:CreateCollisionGroup("Minions") pS:CollisionGroupSetCollidable("Minions", "Minions", false) while script.Parent.Building.Health.Value > 0 do wait(spawnTime) for i = 1, spawnRate do wait() local dummy = game:GetService("ReplicatedStorage").Minions:GetChildren()[math.random(1, #game:GetService("ReplicatedStorage").Minions:GetChildren())]:Clone() dummy.Parent = script.Parent.Minions for i, v in pairs(dummy:GetChildren()) do if v:IsA("MeshPart") or v:IsA("Part") then pS:SetPartCollisionGroup(v, "Minions") end end dummy.HumanoidRootPart.CFrame = script.Parent.Spawn.CFrame local pFS = game:GetService("PathfindingService") spawn(function() for _, waypoints in pairs(script.Parent.Waypoints:GetChildren()) do local path = pFS:CreatePath() path:ComputeAsync(dummy.HumanoidRootPart.Position, waypoints.Position) local wp = path:GetWaypoints() for __, wp2 in pairs(wp) do dummy.Humanoid:MoveTo(wp2.Position) dummy.Humanoid.MoveToFinished:Wait() end end end) script.Parent.Building.Health.Value = script.Parent.Building.Health.Value - math.random(10, 15) dummy:Destroy() end end
It Happens cause your game may be in R6 Humanoid root parts Are In R15 U can replace the HumanoidRootPart by Humanoid If You Want