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

How would I check if a certain folder gets items in it?

Hello, so I am trying to create an inventory system for morphs. How it works is when items enter the folder, it clones a gui with the information. How do I tell through the script if the folder obtains new items in it? Sorry if this seems like a simple question.

local folder = game.Players.LocalPlayer:WaitForChild("Animals")

local frame = script.Parent.Parent:WaitForChild("Box")

local template = script.Parent:WaitForChild("Template")

for _, animal in pairs(folder:GetChildren()) do
	local newTemplate = template:Clone() -- makes a new gui for the character
	newTemplate.Name = animal.Name
	newTemplate.ObjectName.Text = animal.Name
	newTemplate.Visible = true
	newTemplate.Parent = frame

	local object = animal:Clone()
object.Parent = newTemplate.ViewportFrame

1 answer

✓ Accepted answer

We can use the Instance.ChildAdded event to trigger this. Note that if you want to refer to the child that will be added, you should use :WaitForChild, not Folder.Child.

1 comment

0

thank you very much for your help

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