This was originally working months ago, but now doesn’t. The only thing I’ve changed is I made the blocks MeshParts, instead of normal parts, as they have textures. The sizes and everything have stayed the exact same though
-- GetMouseTarget
return function()
local CursorPosition = UserInputService:GetMouseLocation()
local CameraRay = Camera:ViewportPointToRay(CursorPosition.X, CursorPosition.Y, 0)
local DrawnRay = Ray.new(Camera.CFrame.Position,(CameraRay.Direction * 1000))
return workspace:FindPartOnRayWithWhitelist(DrawnRay, {PlayersIsland.Blocks})
end
-- SnapToGrid
local GridLock = 3
return function(position, n)
local x = math.floor(position.X / GridLock + (n.X >= 0 and 0.5 or -0.5)) * GridLock
local y = math.floor(position.Y / GridLock + (n.Y >= 0 and 0.5 or -0.5)) * GridLock
local z = math.floor(position.Z / GridLock + (n.Z >= 0 and 0.5 or -0.5)) * GridLock
return Vector3.new(x, y, z)
end
-- Get mouse location
local Part, Position, Normal = GetMouseTarget()
if not Part then return end
local RoundedPos = SnapToGrid(Position, Normal) -- Snap returned position to grid
-- Position
CurrentBlock:SetPrimaryPartCFrame(
CFrame.new(RoundedPos) *
CFrame.Angles(0, math.rad(Rotation), 0)
)