Grid/Snap system [Help]


function PlacementController:GetMousePoint(ignoreList)
    if mouse.Target ~= nil then
		local unitRay = camera:ScreenPointToRay(mouse.x, mouse.y)
		
		local raycastParams = RaycastParams.new()
		raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
		raycastParams.FilterDescendantsInstances = ignoreList
		
		local ray = workspace:Raycast(unitRay.Origin, unitRay.Direction * range, raycastParams)
		
		if ray then
			return ray.Position, ray.Instance, ray.Normal
		end
	end
end
	

function PlacementController:Start()
    local ignoreList = {char, Sign}
    RunService.RenderStepped:Connect(function()
        local position, target, normal = self:GetMousePoint(ignoreList)
        if target == game.Workspace.Part  then
            Sign:SetPrimaryPartCFrame(CFrame.new(position) * CFrame.new(0, 2, 0))
        end
        if target == game.Workspace.Week  then    
            Sign:SetPrimaryPartCFrame(CFrame.new(position) * CFrame.new(0, 2, 0))
        end
    end)
end

How can I make a Grid Placement in this case?

if ray then
    return ray.Position, ray.Instance, ray.Normal
end

You could round the position to the nearest whole-number grid coordinate before returning.

Do some searching, this topic has been covered a lot. If you’ve got specific questions that’s fine, but it’s hard to help if we don’t know what your issue is.