So I have a region3 and I noticed that i can't run a function which deletes un-anchored parts in a region without killing players inside the region.
How would I make it so it does not kill players in the region, but delete unknown un-anchored blocks.
(
Ignore = {workspace.Secure,game.Players} local topCorner = script.Parent.TopCorner.Position local bottomCorner = script.Parent.BottomCorner.Position local region3 = Region3.new(bottomCorner, topCorner) while wait(0.5) do local parts = workspace:FindPartsInRegion3WithIgnoreList(region3,Ignore,100) for i = 1, #parts do if parts[i].ClassName == "Part" and parts[i].Anchored == true or parts[i].ClassName == "WedgePart" or parts[i].ClassName == "TrussPart" then -- If I only do "parts[i].ClassName == "Part"" then it kills players. if parts[i].Name == "BottomCorner" or parts[i].Name == "TopCorner" then parts[i]:Remove() else print("Detected "..parts[i].Name.." In Region, ... Deleting ...") end parts[i]:Remove() end end end
If you want to delete all of the unanchored parts in a region that aren't part of a character, check that they aren't inside of a character:
local region3=Region3.new(script.Parent.BottomCorner.Position,script.Parent.TopCorner.Position) while wait(.5)do local parts=workspace:FindPartsInRegion3WithIgnoreList(region3,{workspace.Secure}) for i=1,#parts do local p=parts[i] if p:IsA("BasePart")and not p.Anchored then local character=false for _,v in pairs(game.Players:GetPlayers())do if v.Character and p:IsDescendantOf(v.Character)then character=true break end end if not character then p:Destroy() end end end end