What you can do is use some Roblox built-in CFrame methods.
One I'll be using is vectorToWorldSpace
.
01 | local SidePoint = Instance.new( 'Part' ,workspace) |
02 | local Part = Instance.new( 'Part' ,workspace) |
04 | SidePoint.Anchored = true |
07 | Part.CFrame = CFrame.new( 10 , 10 , 10 ) |
08 | Part.Size = Vector 3. new( 10 , 10 , 10 ) |
09 | Part.Transparency = 0.9 |
10 | Part.BrickColor = BrickColor.new( "Bright red" ) |
13 | [ "Top Face" ] = Part.CFrame:vectorToWorldSpace(Vector 3. new( 0 , 1 , 0 )), |
14 | [ "Bottom Face" ] = Part.CFrame:vectorToWorldSpace(Vector 3. new( 0 ,- 1 , 0 )), |
15 | [ "Back Face" ] = Part.CFrame:vectorToWorldSpace(Vector 3. new( 0 , 0 , 1 )), |
16 | [ "Front Face" ] = Part.CFrame:vectorToWorldSpace(Vector 3. new( 0 , 0 ,- 1 )), |
17 | [ "Right Face" ] = Part.CFrame:vectorToWorldSpace(Vector 3. new( 1 , 0 , 0 )), |
18 | [ "Left Face" ] = Part.CFrame:vectorToWorldSpace(Vector 3. new(- 1 , 0 , 0 )) |
21 | for _,v in pairs (Points) do |
22 | steve = SidePoint:Clone() |
23 | steve.Parent = workspace |
24 | steve.CFrame = CFrame.new(Part.Position + (v* 5 )) |
Basically, vectorToWorldSpace
makes whatever Vector you give it as an argument the new origin of the 3D-grid Roblox goes by. So what we are doing, is taking multiple sides of this 'origin' and basically multiplying it by half the original parts size so it goes right to the border edge of the Part.
Now, to get all the corners, we just need to change up the Vectors a little!
Corners will look like this
Vector3(1,1,1) or V3(1,-1,1)
THERE WILL BE NO 0's
So, let's get the corners this time only:
01 | local SidePoint = Instance.new( 'Part' ,workspace) |
02 | local Part = Instance.new( 'Part' ,workspace) |
04 | SidePoint.Anchored = true |
07 | Part.CFrame = CFrame.new( 10 , 10 , 10 ) |
08 | Part.Size = Vector 3. new( 10 , 10 , 10 ) |
09 | Part.Transparency = 0.9 |
10 | Part.BrickColor = BrickColor.new( "Bright red" ) |
15 | steve = SidePoint:Clone() |
16 | steve.Parent = workspace |
17 | steve.CFrame = CFrame.new(Part.Position + (Part.CFrame:vectorToWorldSpace(Vector 3. new(i,j,k)) * 5 )) |
This will only deal with the numbers, 1 and -1 to ensure we only grab corners.
Dr. Mathematica teaches a bit of it here:
https://www.youtube.com/watch?v=Ys0XCdMA1fE
It gives you a great way of detecting faces!