Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ChildAdded and ChildRemoved not working?

Asked by 7 years ago

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)
0
new.ChildAdded:connect(function(CHILD) end) <-- You're missing that one argument. AstrealDev 728 — 7y
0
Why do you need to do something like this? User#5423 17 — 7y
0
@AstrealDev That's not the problem w/ his script... TheeDeathCaster 2368 — 7y
0
Did you check the Output for errors? Via for studio, or F9 ingame? If so, could you please provide what it said? TheeDeathCaster 2368 — 7y

1 answer

Log in to vote
0
Answered by
RSLR 15
7 years ago

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")

Ad

Answer this question