Basically I need to disable the scripts inside a model which has different models within it that hold scripts, localscripts, and modulescripts. The main model though will be within the script on the tree level. I don't know how to script so that's why I am asking for the code. Sorry for any inconveniences.
(UPDATE: So far can't get any of the first 4 scripts below to work for this. No clue why they don't work guessing scripts don't run in Workspace then idk.
Use :IsA to detect the class of the instance
for i,v in pairs(workspace.Model:GetChildren())do if v:IsA("Script") then v.Disabled=true end end
a for loop would be useful for this.
part=your part for i,v in pairs(part:GetChildren()) do--[[ u could also use :GetDescendants() to get the children of the children]] -- i is the index, v is the value if v:IsA("Script") or v:IsA("LocalScript") then v.Disabled=true end end
tell me if it helped ;)
you would need to loop through all of the models using a pairs loop.
for i,v in pairs() do end)
that is a pairs loop. looks sorta similar to a for i = x,x,x loop. "i" is the index. you can change the index to any letter you want. "v" is the value. you can also change it to any letter you want. pairs is used in tables and getchildren and some other things. there is also ipairs that stops when there is a nil value but that won't be used. in the parentheses, you would put the table or the model where you want to get the children. and whatever is in the parentheses is what the value is.
for i,v in pairs(NameOfTheModelWithScripts:GetChildren()) do end)
since we have access to whatever is in the model, we can change the property. but what if there is another object in the model that isn't a script and doesn't have the disabled property. well, you can use if v:IsA("PutClassName") then or if v.ClassName == "PutClassName" then IsA is recommended "v" inside of one of those if statements would only affect objects with the certain class. but outside of it, it will affect object with any class. the class name is usually the name that the object starts out when inserting an object (that rule doesn't apply for some objects. such as a shirt. when a shirt is inserted, studio will automatically change its name to "Clothing") oh and remember when putting the class name, make sure it includes the capitals. it's case sensitive. oh and the classname is a visible property.
for i,v in pairs(NameOfTheModelWithScripts:GetChildren()) do if v:IsA("ClassNameHere") then --do what ever to the object end end)
for _, v in pairs(Instance:GetChildren()) do -- Remember, v represents all the members of the table when using "in pairs()" if v:IsA("Script") then -- checks if the child is a script v.Disabled = true -- Disables the child end end