Hi, I would like to know if there was a function to check whether a folder's children have changed(They are IntValues). I know how to check them individually, for example:
workspace.Value.Changed:Connect(function() print("changed!") end)
but I want it so that if one of the folder's children changes, a function will do something and if the other children change, the same function will execute.
Please Help!
You can try using an in pairs loop with a changed event like this:
for i,v in pairs (game.Workspace:GetChildren()) do if v:IsA('IntValue') then v.Value.Changed:Connect(function() -- Insert code here end) end end
The for loop will go through all the children in the workspace, then the if statement will check to see if the child is an intvalue, then it will see if the intvalue's value has changed.
If you do not like this method, you can always check for changes in the descendants of the workspace.
The easiest way to accomplish this would be a BindableEvent, like so:
local event = Instance.new("BindableEvent", game.ReplicatedStorage) event.Event:connect(function() print("Changed!") end) for _,v in pairs(folder:GetChildren()) do v.Changed:connect(function() event:Fire() end) end)