Goal: Align the transparent blocks (created by script) with the designated part.
Issue: Grid is off by some amount.
function GridModule.CreateGrid(MapModel, TestModeBool)
if MapModel:IsA("Model") then
print("The target map is a model! Attempting to run.")
local MapSize = MapModel:GetExtentsSize()
local XSize = MapSize.X/4
local YSize = MapSize.Z/4
local MapPivot = MapModel:GetPivot()
print(MapPivot)
print(XSize, YSize)
for x = 1, XSize do
for y = 1, YSize do
local rayOrgin = Vector3.new(MapPivot.X / 2 + (x * 4), 400, MapPivot.Z / 2 + (y * 4)) --Issue is HERE.
local rayDirection = Vector3.new(0, -450, 0)
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Blacklist
rayParams.FilterDescendantsInstances = {MapModel:FindFirstChild("RayIgnore"):GetChildren()}
local rayResult = workspace:Raycast(rayOrgin, rayDirection, rayParams)
if rayResult then
GridModule.GridData[x.."/"..y] = {rayResult.Position, false}
if TestModeBool == true then
local newPart = Instance.new("Part")
newPart.Parent = workspace
newPart.Position = rayResult.Position
newPart.Size = Vector3.new(4,2,4)
newPart.Anchored = true
newPart.Transparency = .5
end
end
end
end
else
warn("WARNING: Attempted map is NOT a model!")
end
end