Trying to clone multiple zombies with function, getting error

Basically I want more and more zombies to come after waves but it doesn’t let me clone more than one zombie when it should be cloning more. plz help


local waves = game.Workspace.Waves.Value
local spawnspots = game.Workspace.SpawnPoints:GetChildren()
local randomItem = spawnspots[math.random(1, #spawnspots )]
local counter = waves

local function cop()
	local orginal = game.ServerStorage["Drooling Zombie"]
	local copy = orginal:Clone()
	wait(0.2)
	copy.Parent = game.Workspace.ZOMBS
	copy:MoveTo(randomItem.Position)
end

game.Workspace.Waves:GetPropertyChangedSignal("Value"):Connect(function()
	for i = counter, 0, -1 do
		cop()
		wait(0.2)
	end
end)



What’s the error you’re receiving? Show console log please.

local function cop()
	local orginal = game.ServerStorage["Drooling Zombie"]
original.Archivable = true
	local copy = orginal:Clone()
	wait(0.2)
	copy.Parent = game.Workspace.ZOMBS
	copy:MoveTo(randomItem.Position)
end

Try this.

Its Archivable property must already be set to true as he stated he is able to clone a single zombie each wave.

Then it looks like one of these 2 functions don’t work twice.

here the fix

local waves = game.Workspace.Waves.Value
local spawnspots = game.Workspace.SpawnPoints:GetChildren()
local counter = waves

local function cop()
local randomItem = spawnspots[math.random(1, #spawnspots )]
	local orginal = game.ServerStorage["Drooling Zombie"]
	local copy = orginal:Clone()
	copy.Parent = game.Workspace.ZOMBS
	copy:MoveTo(randomItem.Position)
end

game.Workspace.Waves:GetPropertyChangedSignal("Value"):Connect(function()
	for i = 1, counter do
		cop()
		wait(0.2)
	end
end)

try this now

It gave me no error, sorry for not clarifying that.

It’s the same outcome with this, sorry

i edit it try now i hope it works fine

The value of waves is only set once, possibly preventing from spawning more than one.

local waves = game.Workspace.Waves.Value

should be

local waves = game.Workspace.Waves

and then every line that reads the Waves value should be changed to waves.Value.

1 Like

I saw this after I solved it but yup you are correct, thanks so much!