I've made a system where a player can place cubes. However, I'm now I'm trying to make a system that makes sure the cubes are placed within a certain region, and if not; it shouldn't get placed.
The region is supposed to cover anything over top of specific part (plot) and within its size.
This is what I got for this specific section of the code. (part is defined further up and is a 3x3 cube)
local plot = game.Workspace.Bases:FindFirstChild(game.Players.LocalPlayer.Name)
if part.Position.Y >= plot.Position.Y then
local min = Vector3.new(plot.Position.X - plot.Size.X/2, plot.Position.Y, plot.Position.Z - plot.Size.Z/2)
local max = Vector3.new(plot.Position.X + plot.Size.X/2, part.Position.Y, plot.Position.Z + plot.Size.Z/2)
local region = Region3.new(min, max)
local parts = workspace:FindPartsInRegion3(region)
print(region)
print(part.Position)
if parts[part] == part then
--And it would theoretically run the code here, there's obviously irrelevant code below this
However, it goes to my else statement every time which is set to just destroy the cube. The printing lines came out as
-37.5, 2.00000596, -469.5, 1, 0, 0, 0, 1, 0, 0, 0, 1; 120, 1.99998808, 120
15, 3, -492
The large span of numbers from the region makes me think maybe I used it wrong? I'm not sure where to go from here.
EDIT : I ran code like this
local guide = Instance.new("Part")
guide.Parent = game.Workspace
guide.Anchored = true
guide.Size = region.Size
guide.CFrame = region.CFrame
to see the exact size and shape of the region. I then came to the conclusion, I had done the region right as it was exactly how it should be. This makes me even more confused however.

3 comments
You're not doing anything wrong, it's just printing the region and the part's position
also use vector3
but the script isn't working? it's going to else. Does it have to do for how I scanned for the part in the region?