Hey can somebody help me with this? I’m making a placement system but I’m having issues getting this to work on a grid system. I want it to move on a grid of 0.2x0.2 but these examples I see everywhere are ridiculous. Here’s the code:
function placementVector(dt)
if curObj and isPlacing then
mouse.TargetFilter = curObj
local origin = mouse.Hit.p + Vector3.new(0, 0.1, 0)
local ray = Ray.new(origin, Vector3.new(0, -1, 0))
local h, p, normal = workspace:FindPartOnRay(ray, curObj)
local cross = Vector3.new(0, 1, 0):Cross(normal)
local angle = math.asin(cross.magnitude)
curObj:SetPrimaryPartCFrame(curObj.PrimaryPart.CFrame:lerp(CFrame.new(p + normal * curObj.PrimaryPart.Size.y/2) * CFrame.fromAxisAngle(cross.magnitude == 0 and Vector3.new(1) or cross.unit, angle) * data.curPos * data.curRot,dt*8))
end;
end;