Some more information about the background to the case would be useful, Clemfandango.
However the law is remarkably straightforward. If you accepted a tenancy deposit (in respect of a tenancy commencing on or after 6th April 2007), and failed to pay it into an authorised deposit scheme, then a court must either order that the sum should now be paid into such a scheme or order that the deposit be returned to the tenant. (Given that your post would seem to imply that the tenancy has now ended, only the second option would be available to the court).
[Housing Act 2004, Section 214 (3)]
Upon making such a ruling, the court MUST also order the landlord to pay the tenant a sum equal to three times the deposit.
[Housing Act 2004, Section 214 (4)]
http://www.legislation.gov.uk/ukpga/2004/34/part/6/chapter/4
So, if you failed to pay a tenancy deposit into a relevant scheme, you'll be wasting your time by seeking to defend the action. That applies even if the tenant totally wrecked the property, to such an extent that it had to be demolished. You have no right to retain any part of the deposit in respect of such damage; you must issue a formal demand for compensation from the tenant and then, if that fails, commence a totally separate court action. (You can't 'counter claim' under the existing action).