local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local GridSize = 2
local Part = workspace.Part
local function snap()
local PosX = math.floor(mouse.Hit.X / GridSize + 0.5) * GridSize
local PosY = math.floor(mouse.Hit.Y / GridSize + 0.5) * GridSize
local PosZ = math.floor(mouse.Hit.Z / GridSize + 0.5) * GridSize
return PosX, PosY, PosZ
end
game:GetService("RunService").RenderStepped:Connect(function()
mouse.TargetFilter = Part
local posx, posy, posz = snap()
local unitRay = mouse.UnitRay
Part.CFrame = Part.CFrame:Lerp(CFrame.new(posx, posy, posz) * CFrame.new(0, Part.Size.Y / 2, 0), 0.4)
end)
The parts intersect. I need help finding a way to prevent this.