Basically, I want to connect a function to child removed event like so
local folder = workspace.Folder local function onRemove(itemRemoved) -- how can i get the folder that the item was removed from? end folder.ChildRemoved:Connect(onRemove)
I want to write a function once and connect it to many different folders; however, I don't know how to access the folder because i cant do
local function onRemove(itemRemoved) itemRemoved.Parent end
because the itemRemoved has had its parent changed.
Does anyone know a way to get the parent it was removed from without doing an anonymous function?
If anyone comes across this situation in the future, one thing I did to fix this is create a function and run it inside of the connected event function like so
local folder = workspace.Folder local function onRemove(itemRemoved) end folder.ChildRemoved:Connect(function(itemRemoved) onRemove(itemRemoved) -- call the function here and pass the value end)