I want the script to notice a change in a folder called “Bosses” and see how many children are located there. I’ve made a script for it, but whenever I press play and a child gets added in the “Bosses” folder, the script takes no notice of it, and it outputs ‘0’ for ever child added and so on.
How do I make it notice a change in the folder?
Please pelase, help me out on this, I am confused. I have tried moving the script into the parent of the folder(which is another folder that 'Bosses" is in), tried moving it to workspace, and the script was parented in ServerScriptService, and yet it won’t notice any changes.
Here is a part of the script:
local CurrentBosses = script.Parent.Bosses:GetChildren()
local SpawnedEnemies = script.Parent.Enemies:GetChildren()
task.spawn(function()
while task.wait() do
print(#CurrentBosses) -- this is what I want to figure out.
if #SpawnedEnemies ~= workspace.Game.Debris.Mobs.MobsLimit.Value and #SpawnedEnemies < workspace.Game.Debris.Mobs.MobsLimit.Value and #CurrentBosses == 0 then
local BiomeEnemies = game.ReplicatedStorage.BiomeEnemies
local SelectedBiome = BiomeEnemies:FindFirstChild(Biome.Value)
--
local EnemySpawns= workspace.Game.Debris.Mobs.MobSpawns:GetChildren()
local Enemies = SelectedBiome.Enemies:GetChildren()
local SelectedEnemy = Enemies[math.random(1,#Enemies)]:Clone()
SelectedEnemy.Humanoid.BreakJointsOnDeath = false
SelectedEnemy.PrimaryPart.CFrame = EnemySpawns[math.random(1,#EnemySpawns)].CFrame
SelectedEnemy.Parent = workspace.Game.Debris.Mobs.Enemies
SelectedEnemy.Humanoid.Died:Connect(function()
require(game.ReplicatedStorage.ModuleScripts.Ragdoll).Ragdoll(SelectedEnemy)
game.Debris:AddItem(SelectedEnemy,2.5)
end)
end
task.wait(Random.new():NextNumber(.1,15))
end
end)