I am trying to make a zombie spawn. I have tried using this script and no errors appear but it doesn't work (Server Script inside of a part)

-- variables
local wtime = (math.random(5)) 
local ztospawn = (math.random(3)) -- determines which type of zombie to spawn
local numofzombies = game.Workspace.zspawn1.NumberOfZombies -- Int Value in replicated storage which shows how many zombies are in the map.
local zombies = game.ReplicatedStorage.Zombies -- where the actual zombies are stored

while true do
	wait() -- Makes sure script doesn't crash
	if numofzombies.Value == numofzombies.Value < 5 then
		wait(wtime)
		if ztospawn == 1 then
			local clone1 = game.ReplicatedStorage.Zombies.Normal:Clone()
			clone1.Parent = script.Parent.Parent
			numofzombies.Value = numofzombies.Value + 1
			clone1.Position = script.Parent.Position
		end
		if numofzombies.Value == numofzombies.Value < 5 then
			wait(wtime)
			if ztospawn == 2 then
			local clone2 = game.ReplicatedStorage.Zombies.Fast:Clone()
			clone1.Parent = script.Parent.Parent
			numofzombies.Value = numofzombies.Value + 1
			clone1.Position = script.Parent.Position
		end
		if numofzombies.Value == numofzombies.Value < 5 then
			wait(wtime)
			if ztospawn == 3 then
			local clone3 = game.ReplicatedStorage.Zombies.Brute:Clone()
			clone3.Parent = script.Parent.Parent
			numofzombies.Value = numofzombies.Value + 1
			clone1.Position = script.Parent.Position
		end
	end
end

3 comments

0

Does it not work online and offline?

0

Yes you are using it correctly :)

0

I don't think you can use integers in variable names