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

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

Log in to vote
0
Answered by
ACHRONlX 255 Moderation Voter
3 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 — 3y
Ad

Answer this question