This script is inside a part that detects other parts and see's whether or not the name of the part it's detecting is valid. If the part's name is valid then it will be unanchored and fall through the map. What I'm trying to do is make the script not have any delays when detecting the parts so it'll just check any part and unanchor it quickly. I'm not sure what to do now but if anyone has any suggestions I would really appreciate!
local childList = {} local Min = 0 while true do function checkObject(obj) if (obj ~= script.Parent) and (obj.Name == "Breakable") then table.insert(childList,obj) elseif (obj.className == "Model") or (obj == workspace) then local child = obj:GetChildren() for x = 1, #child do if child[x].ClassName == "Model" then checkObject(child[x]) elseif child[x].Name == "Breakable" then table.insert(childList,Min,child[x]) end end obj.ChildAdded:connect(checkObject) end end checkObject(workspace) if Min < #childList then Min = Min + 1 wait() else Min = 1 wait() end local child = childList[Min] if (child ~= script.Parent) then local dis = (child.Position-script.Parent.Position).magnitude if dis <= 200 then child.Anchored = false child.CanCollide = false table.remove(childList,Min,child) Min = Min - 1 wait() end wait() end wait() end
remove wait() and add game:GetService("RunService").RenderStepped:wait() try this.