Zombie Spawner not working

So I have used this tutorial on how to make a zombie waved game. My maps were working as it was suppose to but, when I came into making the spawned for the zombies, it did not work as shown. I did how the person made it but, it still would not work. (I did added a few tiny tweaks of my own) Can someone explain on how I can fix this? I am also very new to Roblox scripting.

Tutorial: ROBLOX ~ How to make a Zombie Game (PART 3): Zombie Spawns - YouTube

-- while true do
	if game.ReplicatedStorage.Values.gameInProgress.Value == true then
		if game.ReplicatedStorage.Values.zombiesRemaining.Value > 6 then
			local NPC = game.ReplicatedStorage.Zombie:Clone()
			NPC.Parent = workspace
			NPC.UpperTorso.CFrame = script.Parent.CFrame
			game.ReplicatedStorage.Values.zombiesRemaining.Value = game.ReplicatedStorage.Values.zombiesRemaining.Value - 1
		end
	end
	wait(1)
end
1 Like

Any errors in the output?

Also, why did you put this as a comment, a valid loop is crucial here.

2 Likes

I am sorry what does that mean? I do not have any experience of coding.

1 Like

The output window informs you about any errors with detail.
It can be turned on via the “View” window.

Putting “- -” before a line of code, will make it invalid and will mark it as a comment.
It is used to organise scripts most of the time, any code with two dashes won’t work.
Try removing them.

1 Like

Oh, sorry for that. I messed up with sending the script. The real code does not have that. But when I test it, the zombie spawner does not work. I am looking at the output and nothing is showing anything wrong. But in the game, the spawner will not spawn the zombies.

1 Like

Alright, no problem.

Do any errors appear when you run the script?

1 Like

No. Nothing. The teleport shows it has worked and chosen a random one but for the zombie spawner, nothing happens in the game or in the output.

1 Like

It is showing nothing in the output bar because you have no added any print statements. Each time you call the print() it prints to the output bar whatever is found in there. Looking at your code, I don’t see any print statements which is why nothing is happening in the bar.

1 Like

Don’t really have experience with NPC’s but it is possible that changing the CFrame of the UpperTorso instead of its HumanoidRootPart is breaking the NPC model itself? This of course only applies that you’re using a R6/R15 based NPC.

1 Like
while true do
	if game.ReplicatedStorage.Values.gameInProgress.Value == true then
		if game.ReplicatedStorage.Values:WaitForChild("zombiesRemaining").Value > 6 then
			local NPC = game.ReplicatedStorage.Zombie:Clone()
			NPC.Parent = workspace
			NPC.UpperTorso.CFrame = script.Parent.CFrame
			game.ReplicatedStorage.Values.zombiesRemaining.Value = game.ReplicatedStorage.Values.zombiesRemaining.Value - 1
	end
end
wait(1)
end

This seems to be working for me, do you want to be amount of remaining zombies to be greater or lower than 6? For me it worked with 7.

1 Like

I think they were specifically looking for errors.

1 Like

The reason it looks like is because you have a statement that if the values of zombies remaining are greater than 6 then the rest of the code outputs. I’m guessing that your value of zombies is less than 6?

2 Likes

Probably that’s the issue, I think he used the wrong operator or gave a wrong value.

1 Like

One of the if statements there must be false. When you run the code, it will go through each statement and if it’s true then it continues. If it’s false, than nothing will happen and your code will not run.

1 Like

instead of just typing two if statement you could Just use like this

if game.ReplicatedStorage.Values.gameInProgress.Value == true and game.ReplicatedStorage.Values.zombiesRemaining.Value > 6 then

1 Like

I checked it, first one printed but the second one didn’t. I changed the value to something greater than 6 and it worked, as I mentioned he probably messed up with the operator.

1 Like

Format the code using the ```.

2 Likes

Yeah, I believe that is his issue there. Thanks!

1 Like

I think if the value is greater than 6 then it will clone a zombie but if its lower then it wont so i assume you should make it so the value of zombiesRemaining should be less than 6 , so as Mart_Dev said, if its Greater than 6 then it will trigger the print() command

if game.ReplicatedStorage.Values.zombiesRemaining.Value > 6 then
    print("Test")
end

Edit: thx jumbopushpop112 for telling me how to formate code

3 Likes