RunService not changing for loop's GetChildren()'s Values that are Returned

Hello! No matter what I do, this run service only adds Enemies to the Kill reg that are already in the Folder in the workspace that were there Prehand. Not when new enemies are added:

RunService.Heartbeat:Connect(function(delta)
	Check += delta
	if Check > 3 then
		print("Checking For Enemies..")
		Check = 0
		for i,v in pairs(CreaturesFolder:GetChildren()) do
			if v:IsA("Model") and v:FindFirstChild("Humanoid") and v:IsDescendantOf(CreaturesFolder) then
				if v.Humanoid:FindFirstChild("InKillReg") then return end
			warn("Creature Found: " .. tostring(v) .. " Adding to KillReg")
				CreatureAdded(v)
			else
				warn("No Humanoids Found In Enemies Folder")
			end
		end
	end
end)

It never adds new enemies into the kill reg, I don’t need to paste the full script since the only issue is the RunService. (It only prints " wanr(“Crteature Found: " … tostring(v) … " Adding to KillReg”)" when there’s something in that folder already not when something is added to it. Same issue occurs when I try to do .ChildAdded (It doesn’t work)

Is ChildAdded completely nonfunctional or does it print when a new instance is added accordingly? I’m unsure as to why it would be failing.

Last time I used it didn’t do anything at all when I added a new Child, if it helps any the Script is in ServerScriptStorage but I doubt that’ll make any difference.

Like it just didn’t fire at all.

Are you sure you’re connected to the correct folder and that folder is having its instances added correctly? ChildAdded shouldn’t be failing to fire like that unless one of those two things has occurred.

Allthough sometimes I’ll be real with you when evber I try to do something new it doesn’t work at all at the start then randomly later down the line it just starts working for me, I am really not sure like if it’s a me problem or so. I am probably going to guess I am going to try to do .ChildAdded and it’s going to work.

Tried this just now and it didn’t fire at all.

CreaturesFolder.ChildAdded:Connect(function(ChildAdded)
	print(ChildAdded)
end)

Assuming your CreaturesFolder reference is correct, is there anything above that connection that may prevent it from establishing? (Ex: Infinite loop that yields luau)



local Players = game:GetService("Players")
local RunService =    game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local CreaturesFolder = workspace:WaitForChild("Creatures")
local Debris = require(ReplicatedStorage.Modules.BetterDebris)




local function CreatureAdded(Creature)	
	local CreatureHumanoid = Creature:FindFirstChild("Humanoid")
	local AlreadyInKillReg = Instance.new("BoolValue")
	AlreadyInKillReg.Name = "InKillReg"
	AlreadyInKillReg.Value = true
	AlreadyInKillReg.Parent = CreatureHumanoid
	if not CreatureHumanoid then warn("Selected Creature: " .. tostring(Creature .. " Does not have a Humanoid ")) return end
	Creature.Humanoid.Died:Connect(function()
		Debris.AddItem(Creature, 4)
		for _, v in ipairs(CreatureHumanoid:GetChildren()) do
			if v.Name == "EnemyDamage" then
				local dmg = v:GetAttribute("Damage")
				local player = v:GetAttribute("Player")
				if not (dmg and player) then return end
				local Killer = game.Players:FindFirstChild(player)
				if Killer then
					local CrystalAmount = CreatureHumanoid:GetAttribute("Crystals")
					print("Creature Killed Rewarding " .. CrystalAmount .. " crystals")
					Killer.leaderstats.Crystal.Value += CrystalAmount
				end
			end
		end
	end)
end

local Check = 0
CreaturesFolder.ChildAdded:Connect(function(ChildAdded)
	print(ChildAdded)
end)
RunService.Heartbeat:Connect(function(delta)
	Check += delta
	if Check > 3 then
		print("Checking For Enemies..")
		Check = 0
		for i,v in ipairs(CreaturesFolder:GetChildren()) do
			if v:IsA("Model") and v:FindFirstChild("Humanoid") and v:IsDescendantOf(CreaturesFolder) then
				if v.Humanoid:FindFirstChild("InKillReg") then return end
			warn("Creature Found: " .. tostring(v) .. " Adding to KillReg")
				CreatureAdded(v)
			else
				warn("No Humanoids Found In Enemies Folder")
			end
		end
	end
end)

This is the entire script, I am pretty sure nothing here Cuases a yield of any sort. that I know of.

I checked the ChildAdded, it functions just fine on my end. Are you ABSOLUTELY SURE that CreaturesFolder is defined correctly and there isn’t any yields for the :WaitForChild() calls at the top?

local CreaturesFolder = workspace:WaitForChild("Creatures")
local Debris = require(ReplicatedStorage.Modules.BetterDebris)

if not CreaturesFolder then
	error("Folder Not Found")
else
	warn("Folder Found")
end

RobloxStudioBeta_4XPl2OBBKx

I unironically swear my RobloxStudio is like Cursed with something. and the rest above the folder varriable are Services using :GetService()

Do you have multiple folders named Creatures…?

Nope.
chrome_sb4Rghpv7G

I’m gonna assume you don’t have any other instances named Creatures that are children of Workspace either. How strange.

I know, I am noi sure why this even happens in the first place.

Have you tried parenting a random object to Creatures in Run mode?

Specifically in run mode?
I’ve been doing Play mostly

It worked in Runmode but not play

Okay, I think I may know what’s happening. Are you parenting objects to CreaturesFolder via a LocalScript?