Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't the parts unanchor?

Asked by
JJ_B 250 Moderation Voter
9 years ago

I made a script that unanchors all parts in the map when a value gets to 0. However, when this happens,only some parts unanchor and there's no errors in the output. Here is the script;

s = Instance.new("SpawnLocation")

function unanchorAll()
local v = game.Workspace:GetChildren()
for i = 1,#v do
  if v[i]:IsA "Part" or v[i]:IsA "UnionOperation" then
   v[i].Anchored = false
  end
 end
end

while true do
    if game.Workspace.Shields.Value <= 0 then
        unanchorAll()
        game.Workspace.SD:play()
        if game.Workspace:FindFirstChild("borg")~= nil then
            game.Workspace.borg:Destroy()
        end
        wait(4)
        s.Parent = game.Workspace
    end
    wait(2)
    end

Why isn't this working?

1 answer

Log in to vote
0
Answered by 9 years ago

Because some parts maybe be in a model so you need to make an or if v[i]:FindFirstVhild("Part")

0
wat JJ_B 250 — 9y
Ad

Answer this question