Child added argument

So Im trying to make a custom backpack system with childadded

	plr.Backpack.ChildAdded:Connect(function(child)
		print(child) --prints Tool
		local MainGui = plr.PlayerGui.MainGui
		local Tools = MainGui.Tools
		local CloneGuiTool = Tools.Tool:Clone()
		CloneGuiTool.Text = child.Name
		CloneGuiTool.Name = child.Name
		CloneGuiTool.Parent = Tools
		CloneGuiTool.Visible = true
	end)
	plr.Backpack.ChildRemoved:Connect(function(child)
		print(child) --prints GUN
		local MainGui = plr.PlayerGui.MainGui
		local Tools = MainGui.Tools
		Tools:FindFirstChild(child.Name):Destroy()
	end)

The Tool name that gets added is “GUN”

when I print the child argument of the ChildAdded then it just prints “Tool” but when I remove the tool from the backpack and I print the Argument of the ChildRemoved then it prints GUN, how do I make the same thing happen with the child Added?

1 Like

Try printing child.Name

30 chars

When the tool is added, try putting

print(child.Name)

and see if it will print its name. It might be it just prints its ClassName the first time.

(nvm someone said that already)

How is the tool being added to the player backpack? The problem might be there. Maybe in another script you are cloning a tool named “Tool”, parenting it to the player’s backpack and then renaming it to “GUN”. By the time ChildAdded fires, the tool wouldn’t have been renamed yet.

2 Likes