So I have a model with a load of scripts. The script (when enabled) enables the particle emitter in each part. So, how would I enable the scripts in each part in the model?
Thanks in advance.
You should not be using a script for each particle emmiter so you should change your code to handle all particle emmiters in one script.
Roblox now includes a function to do this for us and it is far faster than using Recursion. The function is GetDescendants which will return an array of instances belonging to that instance.
Though it is a bad idea to enable and disable scripts you can use the code to do this task.
for _, itm in pairs(ins:GetDescendants()) do if itm:IsA('Script') then itm.Enabled = true end end
I hope this helps.
for i,a in pairs(thing1:GetChildren()) do -- a is the nearest children to the root parent if a:IsA("BasePart") then for i,b in paris(thing2:GetChildren()) do -- b is the children of thing1 if b:IsA("Script") then b.Disabled = false end end end end
Dunno is that what you're asking for :thonk: