Yeah, you’re right, it is my math calculations problem, if you dont understand the:

```
for j = 1, 8 do
local offsetX = (j % 2 == 0) and 0.5 or -0.5
local offsetY = ((j > 4) and -0.5 or 0.5)
local offsetZ = ((j > 2 and j < 7) and 0.5 or -0.5)
vertices[j] = pos + Vector3.new(size.X * offsetX, size.Y * offsetY, size.Z * offsetZ)
end
```

It is just getting position of 8 vertices of a cube, so how I predict, the problem is in this part of code:

```
local visibleSides = {}
for j = 1, 6 do
local normal = (vertices[j + 1] - vertices[j]).Unit:Cross(vertices[j + 2] - vertices[j]).Unit
local toCamera = Camera.CFrame.Position - vertices[j]
if normal:Dot(toCamera) > 0 then
table.insert(visibleSides, j)
end
end
local triangleDrawFunctions = {
[1] = function()
drawTriangle(2,4,6, Color3.new(1, 1, 0))
drawTriangle(2,6,8, Color3.new(1, 1, 0))
end,
[2] = function()
drawTriangle(2,7,8, Color3.new(0, 1, 0))
drawTriangle(2,7,1, Color3.new(0, 1, 0))
end,
[3] = function()
drawTriangle(1,3,7, Color3.new(0, 0, 1))
drawTriangle(3,7,5, Color3.new(0, 0, 1))
end,
[4] = function()
drawTriangle(3,4,5, Color3.new(0,1,1))
drawTriangle(4,5,6, Color3.new(0,1,1))
end,
[5] = function()
drawTriangle(1,2,3, Color3.new(1, 0, 0))
drawTriangle(2,3,4, Color3.new(1, 0, 0))
end,
[6] = function()
drawTriangle(5,6,7, Color3.new(1, 0, 1))
drawTriangle(6,7,8, Color3.new(1, 0, 1))
end
}
for _, side in visibleSides do
if triangleDrawFunctions[side] then
triangleDrawFunctions[side]()
end
end
```