"child is not a valid member of parent", even though child still exists inside parent

i recently made a global cooldown for tools, which never resets when player character is reset. while i did that, i also made a visual gui that indicates current tool cooling down with a timer
image
everything was fine, until when i wrote a script that copies template to player’s cooldownfolder (where stores all tools’ cooldowns) and tested it, it gave me this error, “child is not a valid member of parent”,


although all children’s were existing inside the object, and all of the scripts i wrote were really fine
image


the source of error was from a local script, at line 13
whats the best solution to fix this annoying bug?

the obj was inside recorded video, please watch fully

I don’t see where OnCooldownAdded is called. Could you point it out to me please?

local CooldownFolder = Player:WaitForChild("CooldownFolder")

if #CooldownFolder:GetChildren() > 0 then
	for _, v in pairs(CooldownFolder:GetChildren()) do
		OnCooldownAdded(v)
	end
end

CooldownFolder.ChildAdded:Connect(OnCooldownAdded)
1 Like

Maybe replace line 13 with this?

TemplateClone.BackgroundColor3 = Obj:WaitForChild("Color").Value

that would not work, i did test it with both WaitForChild() and FindFirstChild(), and it returned with nil value

What were the results from using waitForChild?

it ended up like that, although children still existed inside object (like what i said before)

turns out there was already a thread talking about the same problem

and the way to fix it is to add wait()

i should have dug into it more :moyai: