Hey guys, I tried making a region and then making an Instance to visualize that region, but it sadly doesn’t spawn in the right position. It still spawns in the right size though. Please help, thank you!
local point2 = game.Workspace.Point2 -- Point 1 & 2 are in the white zone.
local point1 = game.Workspace.Point1 -- Their positions are [(-12.735, 31.292, 72.565) & (86.265, 130.289, 171.565)]
local Region1 = Region3.new(point1.Position, point2.Position)
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Size = Region1.Size
part.Parent = game.Workspace
In your code, just add part.CFrame = Region1.CFrame, preferably before or after setting part.Size for organization. This will set the CFrame (Orientation and Position) of the part to the one of the Region3.
I’m not sure I understand how that would work. wouldn’t that just set the Part CFrame to the Region CFrame?
I tried it with the script below and it didn’t change anything: the part is still in its original position.
Keep in mind the part generated only represents the Region and is here only for testing purposes the referred part (for the Region3 position) is r1
local r1 = game.Workspace.Regions["1"]
local Region1 = Region3.new(Vector3.new(-12.735, 31.292, 72.565),Vector3.new(86.265, 130.289, 171.565))
r1.CFrame = Region1.CFrame
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Size = Region1.Size
part.Parent = game.Workspace
You need to set the CFrame of the part you want to represent the region3, if you want to have less trouble, you can just use the solution to this post. Part To Region3 Help?
Which allows you to simply create a region3 that englobes the area the part takes up.
local Region1 = Region3.new(Vector3.new(-12.735, 31.292, 72.565),Vector3.new(86.265, 130.289, 171.565))
Region1.CFrame = CFrame.new(36.265, 31.292, 122.065)
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Size = Region1.Size
part.Parent = game.Workspace
part.CFrame = Region1.CFrame ----- You need to set the new part's Cframe, your region was positioned properly, the part was not.
No, you do not need to set the CFrame of the Region3. Simply use this code:
local point2 = game.Workspace.Point2 -- Point 1 & 2 are in the white zone.
local point1 = game.Workspace.Point1 -- Their positions are [(-12.735, 31.292, 72.565) & (86.265, 130.289, 171.565)]
local Region1 = Region3.new(point1.Position, point2.Position)
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Size = Region1.Size
part.CFrame = Region1.CFrame
part.Parent = game.Workspace