I’m trying to make a placement system and got stuck into a problem for the past 3, basically I have multiple block sizes and I want them to be aligned, but only 4x4x4 are aligned
E.g:
Script I’m using to snap the blocks:
local function GetSnap(Size, Position, Axis)
if Size[Axis] == 1 then
return math.floor(Position[Axis]) + 0.5
else
return math.floor((Position[Axis] / Size[Axis]) + 0.5) * Size[Axis]
end
end
local Result = workspace:Raycast(Mouse.UnitRay.Origin, Mouse.UnitRay.Direction * 500, Params)
if Result and Result.Instance then
local Target = Result.Position + Result.Normal * 1.5
Block.Transparency = 0
Block.PlaceHighlight.Transparency = 0
Block.Position = Vector3.new(
GetSnap(Block.Size, Target, "X"),
GetSnap(Block.Size, Target, "Y"),
GetSnap(Block.Size, Target, "Z")
)
end