Wave Zombie Spawner does not work

Hello! I am making a zombie game with my little cousin, but I can’t seem to get the script that creates the zombies to work. Can you guys help me?

local Event = game.ReplicatedStorage.WaveEnded
local Outgoing = game.ReplicatedStorage.NewWave
local number = game.ReplicatedStorage.ZombieCount

local function NewWave()
	number = number + 1
	Outgoing:FireClient()
end

game.Players.PlayerAdded:Connect(NewWave)

Event.OnServerEvent:Connect(function()
	wait(10)
	NewWave()
end)

That’s the script that handles the server side

local NPC = game.ReplicatedStorage.Zombie --ObjectNameHere
local spawner = script.Parent
local number = game.ReplicatedStorage.ZombieCount
local currentZombieCount = 0
local Outgoing = game.ReplicatedStorage.WaveEnded
local Incoming = game.ReplicatedStorage.NewWave


local function spawnZombie()
	local Clone = NPC:Clone()
	Clone.Parent = workspace
	Clone.Torso.CFrame = spawner.CFrame
end 

Incoming.OnClientEvent:Connect(function()
	repeat
		spawnZombie()
		currentZombieCount = currentZombieCount + 1
		print("Current zombie count: " .. currentZombieCount)
		Outgoing:FireServer()
	until currentZombieCount == number.Value 
end)

This is the client side. Thanks for your help!

1 Like

You’re going to have to provide more information than just the code

What exactly happens? Nothing? Something?

Are there any errors?

Nothing, no errors. It’s what worries me.

The script seems confusing, why would you fire a script to a client to spawn a zombie? exploiters can access any local scripts and make changes to spawn amount of the zombies. How about every wave just clone a new zombie on the ServerScript. Also make sure when using FireClient, you have to provide which player to be fired on the first parameter like example :FireClient(game.Players.JustANormalPlayer103)