From 1 October you can only travel to the United Kingdom with a passport: the DNI will no longer be valid.
In a month’s time, the regulations governing access to the United Kingdom will change. As of October 1, Spaniards wishing to travel to the country will have to carry their passport and will not be able to do so as before, only with their DNI, except for those persons who have their «settled/pre-settled status» linked to the DNI, who will be able to continue using it until December 31, 2025: https://www.gov.uk/guidance/visiting-the-uk-after-brexit
In addition to Spain, most of the states of the European Union, the European Economic Area and Switzerland will also be affected by this modification. More informarion here
Spanish citizens can visit the United Kingdom without a visa maximum of six months if it is a leisure trip or if it is of short duration for work or educational reasons.