So I’m trying to create a Region3 to where I can check if a player is inside. I have the code down to check for the player in the Region3, but the Region3 itself isn’t working for me. I’m pretty new to using Region3s so I don’t know if I’m even doing it right.
local smin = Vector3.new(SallowEnd.Corner1.Position)
local smax= Vector3.new(SallowEnd.Corner2.Position)
local shallowregion = Region3.new(smin, smax)
print(shallowregion.CFrame)
print(shallowregion.Size)
The first print prints, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, and the second one prints out, 0, 0, 0.
I think it is technically creating the region, just for some reason with no size or anything.
Looks like your code is fine. Regions are invisible. To check if a part is in the region you can do this:
local smin = SallowEnd.Corner1.Position
local smax= SallowEnd.Corner2.Position)
local shallowregion = Region3.new(smin, smax)
while wait(0.25) do
local partsInRegion = workspace:FindPartsInRegion3(shallowregion)
for i, v in pairs(partsInRegion) do
print(v)
end
end
Rather than using 2 parts (for min and max) to create the region it’s easier to just create a single invisible part and resize it to fit the region you want and then create the region as follows:
local smin, smax = (SallowEnd.Position - (SallowEnd.Size / 2)), (SallowEnd.Position + (SallowEnd.Size / 2))
local shallowregion = Region3.new(smin, smax)