Well, with the information given, I have no idea how you’re moving the “build” around. I’ll assume it’s based on the mouse position, and you can refine this script using the build’s primary part if needed.
(I’m assuming by “build,” you mean a Module.)
This is an unusual setup, but I like it. You can even use it to determine your zone dimensions generically. I’m placing box Parts inside a folder named “Zones” in the workspace. Together, they match your diagram, so there are four. These serve as zone references and should be transparent, with no shadows, locked, anchored, and massless. No behavior or collision settings. It will handle the “zones” mathematically from these parts, keeping it minimal and update-friendly.
Zone Script
This is a LocalScript in StarterGui … Just to test it.
local rns = game:GetService("RunService")
local zones = workspace:WaitForChild("Zones")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local squares = {}
for _, part in pairs(zones:GetChildren()) do
if part:IsA("Part") then
table.insert(squares, part)
end
end
if #squares == 0 then return end
local minPos = squares[1].Position - squares[1].Size / 2
local maxPos = squares[1].Position + squares[1].Size / 2
for _, square in ipairs(squares) do
local squareMin = square.Position - square.Size / 2
local squareMax = square.Position + square.Size / 2
minPos = Vector3.new(math.min(minPos.X, squareMin.X), math.min(minPos.Y, squareMin.Y), math.min(minPos.Z, squareMin.Z))
maxPos = Vector3.new(math.max(maxPos.X, squareMax.X), math.max(maxPos.Y, squareMax.Y), math.max(maxPos.Z, squareMax.Z))
end
local function isInZone(build)
local buildMin = build.Position - build.Size / 2
local buildMax = build.Position + build.Size / 2
return buildMin.X >= minPos.X and buildMax.X <= maxPos.X and
buildMin.Y >= minPos.Y and buildMax.Y <= maxPos.Y and
buildMin.Z >= minPos.Z and buildMax.Z <= maxPos.Z
end
mouse.Move:Connect(function()
local target = mouse.Target
if target and target:IsA("Part") then
if isInZone(target) then
print("mouse is inside the zone.")
else
print("mouse is outside the zone.")
end
end
rns.Stepped:Wait()
end)
Print Zones
--paste before function isInZone(build)
--in case you would like to try a Region3 approach
for _, square in ipairs(squares) do
print(string.format("Zone: Pos(%.1f, %.1f, %.1f) Size(%.1f, %.1f, %.1f)",
square.Position.X, square.Position.Y, square.Position.Z,
square.Size.X, square.Size.Y, square.Size.Z))
end
This is more of an angle on how you could do this… In a somewhat testing phase.