Panwellz
|
  |
| Joined: 16 Oct 2012 |
| Total Posts: 749 |
|
|
| 15 Mar 2016 09:13 AM |
Just having some trouble making a script cancel a function if the model has atleast 1 anchored part
|
|
|
| Report Abuse |
|
|
Panwellz
|
  |
| Joined: 16 Oct 2012 |
| Total Posts: 749 |
|
| |
|
hkep
|
  |
| Joined: 19 Jul 2014 |
| Total Posts: 550 |
|
|
| 15 Mar 2016 09:32 AM |
function IsNotAnchored(xModel) function GetPartDescendants(Obj) local found = {} for i,o in ipairs(Obj:GetChildren()) do if o:IsA("Part") then table.insert(found, o) else table.insert(found, unpack(GetPartDescendants(o))) end end return found end
local Parts = GetPartDescendants(xModel)
for i=1,#Parts,1 do if Parts[i].Anchored then return false end end
return true end
|
|
|
| Report Abuse |
|
|
Auzer
|
  |
| Joined: 24 Dec 2011 |
| Total Posts: 1590 |
|
|
| 15 Mar 2016 09:43 AM |
@hkep Eww
AnchoredParts = {}
function Search(Parent) for _, v in pairs(Parent:GetChildren()) do if v:IsA("BasePart") and v.Anchored then table.insert(AnchoredParts, v) else search(v) end end end
Search(game.Workspace.Model)
|
|
|
| Report Abuse |
|
|
Panwellz
|
  |
| Joined: 16 Oct 2012 |
| Total Posts: 749 |
|
|
| 15 Mar 2016 10:01 AM |
I tried to make it perform an action if it didn't find any anchored parts:
for _, v in pairs(machine:GetChildren()) do if v:IsA("BasePart") and not v.Anchored then print"success" end end
it didn't print anything
|
|
|
| Report Abuse |
|
|
Auzer
|
  |
| Joined: 24 Dec 2011 |
| Total Posts: 1590 |
|
|
| 15 Mar 2016 12:14 PM |
@Panwellz Have you ever heard of a variable or parent?
|
|
|
| Report Abuse |
|
|
Panwellz
|
  |
| Joined: 16 Oct 2012 |
| Total Posts: 749 |
|
| |
|