How can I make my script detect parts inside of models that are also in the workspace, it’s only picking up parts that are actually parented to the workspace and not the ones inside of models too.
for i,v in pairs(workspace:GetChildren()) do
if v:IsA("Part") then
v:Destroy()
print("Destroyed part")
end
end
if v:IsA("Model") then --detect Model
local part = v:FindFirstChildWhichIsA("BasePart") --Detect part within model
if part then
v:Destroy() -- destroy the model for comprehensive cleaning
--You can also use get children on the model depending on what you want
end
end