You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want to add a limit to how much enemies can spawn.
-
What is the issue? It isn’t counting the children in the folder.
-
What solutions have you tried so far? I have looked for solutions but none of them worked or they were just the same thing I did
Yes there are enemies parented to activeEnemies and I have also called the function
local prepareLength = 1
local messageLength = 10
local inRound = game.ReplicatedStorage.RoundValues.InRound
local status = game.ReplicatedStorage.RoundValues.Status
local roundTime = game.ReplicatedStorage.RoundValues.RoundTime
local enemies = game.ServerStorage.Enemys:GetChildren()
local enemySpawns = game.Workspace.EnemySpawns:GetChildren()
local activeEnemies = game.Workspace.Enemys:GetChildren()
function spawnWave()
if #activeEnemies < 40 then -- Part that is not working
for i = 10, 0, -1 do
local enemyClone = enemies[math.random(1, #enemies)]:Clone()
enemyClone.Parent = workspace.Enemys
enemyClone:SetPrimaryPartCFrame(enemySpawns[math.random(1, #enemySpawns)].CFrame)
end
print(#activeEnemies)
end
end