I am looking for a way to see whenever an item is added to a table, however I’m not sure how to go about it. Is there any way to have a function fire every time an item is added to a table / dictionary, similar to Instance.ChildAdded:Connect() ?
if the item can be taked, then add a function to it
--add at table function
print(script.Parent.Name .."Added to Table!") -- script.Parent.Name if your script at item
if you need to add to save data, use pairs( if you know how) at Save data script
You would have to make a function or module script to do that. There is no table manipulation event because it is a lua type not roblox. You could create a module script like so.
local module = {}
module.addedItemEvent = Instance.new("BindableEvent")
function module.AddItem(t, item)
table.insert(t, item)
module.addedItemEvent:Fire(item)
end
return module
1 Like
This seems to be the answer, thank you.