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

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

Asked by 4 years ago

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.

01local folder = game.Players.LocalPlayer:WaitForChild("Animals")
02 
03local frame = script.Parent.Parent:WaitForChild("Box")
04 
05local template = script.Parent:WaitForChild("Template")
06 
07for _, animal in pairs(folder:GetChildren()) do
08    local newTemplate = template:Clone() -- makes a new gui for the character
09    newTemplate.Name = animal.Name
10    newTemplate.ObjectName.Text = animal.Name
11    newTemplate.Visible = true
12    newTemplate.Parent = frame
13 
14    local object = animal:Clone()
15object.Parent = newTemplate.ViewportFrame

1 answer

Log in to vote
0
Answered by
ACHRONlX 255 Moderation Voter
4 years ago

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.

0
thank you very much for your help Ashton011 30 — 4y
Ad

Answer this question