Generally, a voluntary statement to police isn't automatically illegal, but its use in court is a complicated matter. The key factor is whether it was obtained fairly. Police must adhere to specific guidelines, https://panchanandshaw.com/blog/court-law-guide/