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?
Because some parts maybe be in a model so you need to make an or if v[i]:FindFirstVhild("Part")