for i, v in pairs(parent:GetChildren()) do child.Changed:Connect(function() -- code is written here but it’s the same exact thing end) end
That is really bad practice. Mainly because the script will run the same exact code when a property changes or you make your code ridiculously long because you want different code to run when a specific object is changed and use if statements to check for this.
Instead, make a separate script with
Disabled set to true and set it to false once cloned into the object.
script.Parent.Changed:Connect(function() -- Code here end)
Now that you’ve avoided bad practices, let’s clone this bad boy.
for i, v in pairs(parent:GetChildren()) do local sc = script.ChangeScript:Clone() sc.Parent = v -- set parent first, then enable it sc.Disabled = false -- script must’ve manually been set disabled to true from explorer. set disabled to false so code runs end