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

Why does ChildAdded never fire?

Asked by 6 years ago
script.Parent.ChildAdded:connect(function(child)
    local inventorygui = script.Parent.Parent.PlayerGui.GUIs.Inventory.Inventory.List
    script.Parent.Items.Value = script.Parent.Items.Value + 1
    inventorygui[script.Parent.Items.Value].Text = child.Name
end)

It's a very simple script. When I pasted a line to print on the second line nothing happened however. I verified that the script was in the right place and there was a child being added. Any idea what could be happening?

0
Make sure its a LocalScript User#2146 0 — 6y
0
I switched it over and is still doesn't work :/ SchonATL 15 — 6y
0
It seems like you are making a custom inventory. ChildAdded isn't very reliable, and it is not the best way to go about what you want to do. TheDeadlyPanther 2460 — 6y
0
A different way would be to make an event that fires when an item is added (the event being fired from the source, not from another piece of code like the one you provided). Then just listen for it and add the item using the event. TheDeadlyPanther 2460 — 6y
0
@TheDeadlyPanther: I've never had any trouble with ChildAdded... (However, I agree it isn't the best method for custom inventory. Using ModuleScripts and/or RemoteEvents are better, if you know how to use them.) chess123mate 5873 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

In situations like this, sometimes it's good to confirm that the script is running at all. Possible reasons:

  • The script is disabled
  • It is a LocalScript in some place LocalScripts don't run (ex. as a direct child of the workspace; see the link for the full list)
  • It is a Script not inside the workspace nor ServerScriptService
Ad

Answer this question