Very weird problem when cloning a zombie

So I’ve made my wave manager script… and it works- until it doesn’t. When cloning multiple zombies, they break and go crazy.

Here’s a video.

Yeah I don’t even know were to begin.

At first I though something was wrong with my pathfinding- but I tested it separately and it worked perfectly fine.

So then I though it was my wave manager script. It looks like this.

local serverScriptService = game:GetService("ServerScriptService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local serverStorage = game:GetService("ServerStorage")

local roundStartedEvent = serverScriptService:WaitForChild("roundStarted")
local gameSettings = require(replicatedStorage:WaitForChild("gameSettings"))
local zombieFolder = serverStorage:WaitForChild("zombies")
local zombies = workspace:WaitForChild("zombies")

function startNewWave()
	if not gameSettings.waveInProgress and not gameSettings.intermission then
		gameSettings.waveInProgress = true
		gameSettings.waveNumber += 1
		
		print("Wave number "..gameSettings.waveNumber.." has started!")
		
		for i = 1, 40 + gameSettings.waveNumber do
			local zombie = zombieFolder.Zombie:Clone()
			zombie.Parent = zombies
			zombie.HumanoidRootPart.Position = Vector3.new(0, 25, 0)
			
			zombie.Humanoid.Died:Connect(function()
				gameSettings.numberOfEnemies -= 1
			end)
		end
		
		gameSettings.numberOfEnemies = #zombies:GetChildren()

		repeat task.wait() until gameSettings.numberOfEnemies == 0
		
		gameSettings.waveInProgress = false
		
		print("Wave number "..gameSettings.waveNumber.." has ended!")
		
		gameSettings.intermission = true
		
		print("Intermission...")
		
		task.wait(15)
		
		gameSettings.intermission = false
		
		print("Intermission ended!")
	end
end

roundStartedEvent.Event:Connect(function()
	gameSettings.waveNumber = 0
	
	task.wait(10)
	
	while gameSettings.roundInProgress do
		startNewWave()
	end
end)

I think the problem is on the for loop. No console errors.

Do you have some kind of force being applied to the zombies?

I believe it may be related to how the zombies are handled.

Can you show us what it’s like if there’s only one zombie, and the script controlling the zombies?

Scratch what I just said, you’re spawning the zombies too low so they’re sliding across the map

I’m currently trying to find a fix for this

Edit: it also appears that setting the position of each clone isn’t working for some reason

1 Like

change zombie.HumanoidRootPart.Position = Vector3.new(0, 25, 0) to zombie:PivotTo(CFrame.new(0, 25, 0)). That is just how humanoids are handled.

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