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

Why does ChildAdded never fire?

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?

5 comments

0

Make sure its a LocalScript

0

I switched it over and is still doesn't work :/

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.

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.

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

1 answer

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

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