Why can’t you do that? I don’t know how to do that trough scripts but what I would do is check the 2 coordinates needed and find the distance between them
repeat task.wait() until game:GetService("Workspace"):FindFirstChild("Floors", true)
local MODEL = game:GetService("Workspace"):FindFirstChild("Floors", true):FindFirstChild("Floor1")
local HEIGHTPART = MODEL:FindFirstChildWhichIsA("BasePart")
local SIZE = MODEL:GetExtentsSize()
local CENTER = MODEL:GetPivot()
local VERTICES = {
{1, 1, -1},
{-1, 1, 1}
}
local BOUND1 = (CENTER * CFrame.new(SIZE.X/2 * (VERTICES[1])[1], SIZE.Y/2 * (VERTICES[1])[2], SIZE.Z/2 * (VERTICES[1])[3])).Position
local BOUND2 = (CENTER * CFrame.new(SIZE.X/2 * (VERTICES[2])[1], SIZE.Y/2 * (VERTICES[2])[2], SIZE.Z/2 * (VERTICES[2])[3])).Position
local BOUNDS = {
Vector2.new(BOUND1.X, BOUND1.Z),
Vector2.new(BOUND2.X, BOUND2.Z - 4)
}
local ROWS = 24
local COLS = 24
local GROUND = HEIGHTPART.Position.Y
local HEIGHT = 8
local LINE_COLOR = Color3.fromRGB(156, 54, 89)
local LINE_THICKNESS = 0.1
local LINE_TRANSPARENCY = 0.15
local holePositions = {}
local function castRayGridNormal()
local corner1 = BOUNDS[1]
local corner2 = BOUNDS[2]
local boundIntX = (corner2.X - corner1.X) / ROWS
local boundIntZ = (corner2.Y - corner1.Y) / COLS
for i = 1, ROWS do
for j = 1, COLS do
local x = corner1.X + boundIntX * i
local z = corner1.Y + boundIntZ * j
local rayParams = RaycastParams.new()
local raycast = workspace:Raycast(Vector3.new(x, GROUND + HEIGHT, z), Vector3.new(0, -14, 0), rayParams)
print(raycast)
if raycast == nil then
table.insert(holePositions, Vector3.new(x, GROUND + HEIGHT, z) + Vector3.new(0, -14, 0))
end
end
end
end
castRayGridNormal()
local minX, maxX = math.huge, -math.huge
local minY, maxY = math.huge, -math.huge
local minZ, maxZ = math.huge, -math.huge
for _,v in pairs(holePositions) do
if (v.X < minX) then minX = v.X end
if (v.X > maxX) then maxX = v.X end
if (v.Y < minY) then minY = v.Y end
if (v.Y > maxY) then maxY = v.Y end
if (v.Z < minZ) then minZ = v.Z end
if (v.Z > maxZ) then maxZ = v.Z end
end
local minVector = Vector3.new(minX, minY, minZ)
local maxVector = Vector3.new(maxX, maxY, maxZ)
local centerOfHole = minVector:Lerp(maxVector, 0.5)
print(centerOfHole)
Yes but why can’t you place parts in the sky? If you would place it in the sky there would be no problem at all, make it way bigger than the floor and then you can rayvast getting what you need