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

ChildAdded script not working?

I made a "ChildAdded" script, but it doesn't seem to work. It's supposed to change the text of a Gui in a player when a child is added into the "leaderstats" model. For some reason, it's not working, or even detecting the child being added. I tried a "script.Parent.ChildAdded:connect(function(child)" kind of thing, too, but that doesn't work either. Here's the script:

local function onChildAdded(child)
print("Script has detected a child added")
	script.Parent.Parent.PlayerGui.Notifications.Play.Text = ("1"..child.Name.."added to inventory")
	wait(4)
script.Parent.Parent.PlayerGui.Notifications.Play.Text = " "
end
script.Parent.ChildAdded:connect(onChildAdded)

1 comment

0

Where is the script in the Instance Hierarchy?

1 answer

function onChildAdded(child) --I think you put this in StarterPack I heard that it doesn't work any more so put it in StarterGui.
wait(0.25) --it waits for it to load.
print("Script has detected a child added")
    script.Parent.Parent.PlayerGui.Notifications.Play.Text = ("1"..child.Name.."added to inventory")
    wait(4)
script.Parent.Parent.PlayerGui.Notifications.Play.Text = " "
end
script.Parent.ChildAdded:connect(onChildAdded)

9 comments

0

Actually, this script is cloned into every single "leaderstats" model, which is cloned into every player model (not character).

0

Did you try the code that I gave you?

0

Thanks, it works. Sorry for doubting you before I tried it. I just adjusted it a bit so that in the backpack, it detects the leaderstats model by using "script.Parent.Parent.leaderstats.ChildAdded:connect(onChildAdded)".

0

Reputation pl0x

0

"You need at least 1 reputation before you can upvote".

0

Try now

0

Now it doesn't work. Sadly...

0

MAN, I feel dumb. I needed to put it in the StarterPack... because if I cloned it into the backpack, the backpack would be reset every single death, but the StarterPack would clone it every single death, as well.

0

Use ypcall(function() --script end)

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