Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

ChildAdded and ChildRemoved not working?

These functions don't add or subtract 1 when a child is added to "new."

local num = script.Parent.Parent.num
local new = script.Parent

new.ChildAdded:connect(function()
 num.Value = num.Value + 1
end)

new.ChildRemoved:connect(function()
 num.Value = num.Value - 1
end)

4 comments

0

new.ChildAdded:connect(function(CHILD) end) <-- You're missing that one argument.

0

Why do you need to do something like this?

0

@AstrealDev That's not the problem w/ his script...

0

Did you check the Output for errors? Via for studio, or F9 ingame? If so, could you please provide what it said?

1 answer

✓ Accepted answer

Ahh, I see, try adding this in the approximate line. local part = Instance.new("Part")

-- add some sparkles for i = 1, 3 do Instance.new("Sparkles", part) end

print("Part has " .. #part:GetChildren() .. " children") --> Part has 3 children

part:ClearAllChildren()

print("Part has " .. #part:GetChildren() .. " children")

This discussion is preserved as it was. New answers, comments, and votes are closed.