#Problem:# So I have a part that is sized so that a grid can be generated based on that 1 part's position and size. The issue is the grid loading is off and I would like to know how I could fix it. I would like it so that the 4x4 cubes fill up the entire square. I would like to say beforehand that this script wasn't created from scratch by me.The The grid is supposed to overlap the highlighted part
#Square Image:# https://gyazo.com/e80576797183b946645273288decda29 https://gyazo.com/bbe42eb307d331cf07bface16f9cf845
#Script:#
local function PlaceMarker(v3)
local p = Instance.new("Part")
p.CFrame = CFrame.new(v3)
p.Size = Vector3.new(1, 1, 1)
p.Anchored = true
p.CanCollide = false
p.Color = Color3.new(1, 0, 0)
p.Material = Enum.Material.Neon
p.Parent = workspace
end
local function CreateGridFromBase(base, gridSize)
local px, py, pz, sx, sz = base.Position.X, base.Position.Y, base.Position.Z, base.Size.X, base.Size.Z
px, pz = px - sx / 2, pz - sx / 2
local rotCFrame = base.CFrame - base.CFrame.p
local gridParts = Instance.new("Folder")
gridParts.Name = "GridParts"
print(px - sx / 2, px + sx / 2, pz - sz / 2, pz + sz / 2)
PlaceMarker(Vector3.new(px - sx / 2, py, pz - sz / 2))
PlaceMarker(Vector3.new(px + sx / 2, py, pz + sz / 2))
for x = px - sx / 2, px + sx / 2, gridSize do
for z = pz - sz / 2, pz + sz / 2, gridSize do
local p = Instance.new("Part")
p.Anchored = true
p.CanCollide = false
p.Transparency = 1
p.CFrame = CFrame.new(x, py+0.05, z)
p.Size = Vector3.new(gridSize, 1, gridSize)
p.Parent = gridParts
end
end
gridParts.Parent = base
return gridParts
end
NOTE The size of the square was sized so that it would dividable by 4.
Thank you for attempting to assist me!
BlackOrange3343 ~ I'm bad at math.
