currently i have a script that simulates destroypartfallheight, but it uses table.find even after a couple of checks and it runs every frame so it will be horribly laggy at large workspace sizes
local pieces = {}
local atty = {}
for i, v in workspace.SpawnedRooms:GetDescendants() do
if v:IsA("BasePart") then
table.insert(pieces, v)
end
if v:IsA("Attachment") then
table.insert(atty, v)
end
end
local basis = CFrame.new()
local centerLocal, sizeLocal = daft:computeBoundingBox(basis, pieces, atty)
if sizeLocal.X <= 0 and sizeLocal.Y <= 0 and sizeLocal.Z <= 0 then
return -- nothing to do
end
sizeLocal *= 30
local half = sizeLocal * 0.5
local minLocal = centerLocal - half
local maxLocal = centerLocal + half
local worldMin = basis:PointToWorldSpace(minLocal)
local worldMax = basis:PointToWorldSpace(maxLocal)
local regionMin = Vector3.new(
math.min(worldMin.X, worldMax.X),
math.min(worldMin.Y, worldMax.Y),
math.min(worldMin.Z, worldMax.Z)
)
local regionMax = Vector3.new(
math.max(worldMin.X, worldMax.X),
math.max(worldMin.Y, worldMax.Y),
math.max(worldMin.Z, worldMax.Z)
)
regionMax += Vector3.new(500, 500, 500)
local notdeathregion = Region3.new(regionMin, regionMax)
local thingie = workspace:FindPartsInRegion3(notdeathregion, nil, math.huge)
for i, v in workspace:GetDescendants() do
if v:IsA("BasePart") then
if v.Anchored == false then
if not table.find(thingie, v) then
if v.Name == "Key" and v:FindFirstAncestorWhichIsA("Folder") then
local x = keyspawner.Position.X + daft:randrand(-keyspawner.Size.X/2,keyspawner.Size.X/2, true)
local y = keyspawner.Position.Y + daft:randrand(-keyspawner.Size.Y/2,keyspawner.Size.Y/2, true)
local z = keyspawner.Position.Z + daft:randrand(-keyspawner.Size.Z/2,keyspawner.Size.Z/2, true)
v.AssemblyLinearVelocity *= 0.5
v.AssemblyAngularVelocity *= 0.5
v.CFrame = CFrame.new(x, y, z)
continue
end
if v.Parent:FindFirstChild("Humanoid") ~= nil then
v.Parent.Humanoid.Health = 0
elseif v.Anchored == true then
continue
else
v:Destroy()
end
end
end
end
end


