How do you find the exact location of a parts edge? I want to make some sort of randomly generated spawnpoint and I have no clue on where to start.

If you want to achieve something like that, youâ€™ll need to use a little bit of math. Iâ€™m assuming you want to find the four edge points of your part, correct? Essentially what youâ€™re trying to do is find the position of your part + X / 2 or Y / 2 and their reverse.

Just think of your part as a 3D graph and youâ€™re trying to find four points related to the center. Iâ€™ll give you a head start: If you want to find one of your corners you can simply do.

```
local corner = part.CFrame * CFrame.new(part.Size.X / 2, part.Size.Y / 2, part.Size.Z / 2)
```

This will involve a lot of repetitive math but itâ€™s a good mental exercise, I wish you luck and I hope you can understand this concept and execute it yourself.

You can get the size of the part and divide each axis by 2. I prefer to multiply by 0.5 as multiplications are quicker than divisions in computing.

`local PartHalfSize = Vector3.new(Part.Size.X * 0.5, Part.Size.Y * 0.5, Part.Size.Z * 0.5)`

Now that we have half the Partâ€™s size on each axis. We can use CFrame to expand from the center position of the part using its existing orientation.

```
local Part = workspace.Part -- The main Part.
local Marker = workspace.Marker -- A smaller part to visualize the corner.
local PartHalfSize = Vector3.new(Part.Size.X * 0.5, Part.Size.Y * 0.5, Part.Size.Z * 0.5)
wait(2)
Marker.CFrame = Part.CFrame * CFrame.new(PartHalfSize.X, PartHalfSize.Y, PartHalfSize.Z)
wait(2)
Marker.CFrame = Part.CFrame * CFrame.new(PartHalfSize.X, PartHalfSize.Y, -PartHalfSize.Z)
```

You can test the code above by creating a Part and a secondary, smaller Part named â€śMarkerâ€ť to visualize where the points are according to the CFrame. You just have to enter every combination in the directional CFrame to pinpoint every corner. You can even automate the process to mix and match all possible axis combinations.

Do you need to understand math?

Well, not any advanced math, you just need to be able to visualize exactly what you are doing by dividing or multiplying these values. It might be a little foggy at first but it surely becomes easier as you grasp the concept.

Lets give this a go. We start from the center of the part in object space. Then we take half of the size of each axis and add it to our position. You can do this twice per axis (the left and right direction for example). Then we can transform the position in object space to world space.

```
local halfSize = part.Size / 2
local edgePositions = {}
for xSign = -1, 1, 2 do
local localEdgePosition = halfSize * Vector3.new(xSign, 1, 1)
local edgePosition = part.CFrame:PointToWorldSpace(localEdgePosition)
table.insert(edgePositions, edgePosition)
end
```

Not that we have solved the problem for one axis, we can apply the same approach to every axis:

```
local function getEdgePositions(part)
local halfSize = part.Size / 2
local edgePositions = {}
for xSign = -1, 1, 2 do
for ySign = -1, 1, 2 do
for zSign = -1, 1, 2 do
local localEdgePosition = halfSize * Vector3.new(xSign, ySign, zSign)
local edgePosition = part.CFrame:PointToWorldSpace(localEdgePosition)
table.insert(edgePositions, edgePosition)
end
end
end
return edgePositions
end
```

Oh, I solved the problem for getting every cornerâ€¦ Its getting lateâ€¦

thanks foh the replies here, iâ€™m gonna experiment with these.