I am confused on how to fix this. How do I change the position of a Region3? I tried using CFrame to move the region, but it didn’t work.
15:16:14.287 - CFrame cannot be assigned to ^ on line 5
local Point2 = Vector3.new(0.84,3.1,78.862)
local Region = Region3.new(Point1, Point2)
local res = 4
Region.CFrame = CFrame.new(0.84,3.1,68.862)
Region = Region:ExpandToGrid(res)
for _,Part in pairs(game.Workspace:FindPartsInRegion3(Region,nil,math.huge)) do
print(Part.Name)
end```
Your region is determined by two points in the workspace using vector3. You can change the position of a region3 by changing the two points respectively. I.e having two parts then a center part then making it a model and setting the models PrimaryPartCFrame.
If you plug their positions into a region3 getting the math.min and math.max of both part’s X,Y,Z on a vector3 position. Your region3 will be approximately that box.
Oh! So you would get the position of part0 and part1, then make a Region3 with it. Do you need to convert anything, though? (for example, CFrame.Angles(0,math.rad(90),0))
So math.min and math.max work in the same fashion with different returnvalues. math.min, you input two number values and it returns the smallest one. So in my case of an out of bounds script for a hockey game.
which makes a vector3 of the smallest positions based on two parts “OOP1” and “OOP2” which are two points which make the “Out of play” box. math.max is the same, but it returns the highest value.
local Point1 = Vector3.new(math.min(RegionFolder.Part.Position.X,RegionFolder.Part2.Position.X),math.min(RegionFolder.Part.Position.Y,RegionFolder.Part2.Position.Y),math.min(RegionFolder.Part.Position.Z,RegionFolder.Part2.Position.Z))
(point2 having math.max) and regionfolder already being a variable