When God gave them commandments did He also give them the ability to obey him? I want to know did they have the Holy Spirit as a nation of people in the OT? I also would like to know did a person need the Holy Spirit in the OT to be able to obey God?
No one in the Old Testament was born again, meaning that they did not have a new heart nor the mind of Christ. Ezekiel prophesied about what was to come in the New Covenant.
(Eze 36:26 NKJV) I will give you a new heart and put a new spirit within you; I will take the heart of stone out of your flesh and give you a heart of flesh.
(Eze 36:27 NKJV) I will put My Spirit within you and cause you to walk in My statutes, and you will keep My judgments and do them.
The purpose of the Old Covenant was to demonstrate to Israel that they were sinful and in need of a savior.
(Rom 3:19 NKJV) Now we know that whatever the law says, it says to those who are under the law, that every mouth may be stopped, and all the world may become guilty before God.
(Rom 3:20 NKJV) Therefore by the deeds of the law no flesh will be justified in His sight, for by the law is the knowledge of sin.
God did at times keep the hedge up around Israel and cause temporary periods of outward obedience, but their hearts were always hard and unconverted.
(Isa 63:17 NKJV) O LORD, why have You made us stray from Your ways, And hardened our heart from Your fear? Return for Your servants’ sake, The tribes of Your inheritance.
The Spirit of God did not come into anyone and convert their heart and mind until Pentecost in Acts chapter 2, everyone prior to that was yet carnal. That is why this is said about John the Baptist.
(Luk 7:28 NKJV) For I say to you, among those born of women there is not a greater prophet than John the Baptist; but he who is least in the kingdom of God is greater than he.”
To be in the Kingdom of God we must be born again, so no one under the Old Covenant was in the Kingdom of God.
(Joh 3:3 NKJV) Jesus answered and said to him, “Most assuredly, I say to you, unless one is born again, he cannot see the kingdom of God.”
(Joh 3:4 NKJV) Nicodemus said to Him, “How can a man be born when he is old? Can he enter a second time into his mother’s womb and be born?”
(Joh 3:5 NKJV) Jesus answered, “Most assuredly, I say to you, unless one is born of water and the Spirit, he cannot enter the kingdom of God.
(Joh 3:6 NKJV) That which is born of the flesh is flesh, and that which is born of the Spirit is spirit.
The Old Covenant is quite different from the New. This is a big study but it will explain the difference between the two and that may help answer your question:
Please let me know if you need me to further clarify anything for you.