We know that Old Testament saints were saved. They were saved on credit, having faith in God.
The Bible says, "Even so Abraham believed God, and it was reckoned to him as righteousness. Therefore, be sure that it is those who are of faith who are sons of Abraham. The Scripture, foreseeing that God would justify the Gentiles by faith, preached the gospel beforehand to Abraham, saying, 'All the nations will be blessed in you.' So then those who are of faith are blessed with Abraham, the believer." (Galatians 3:6-9)
So the Bible teaches that people are saved by faith in God. A short form of the gospel was even preached to Abraham (Galatians 3:8). And Abraham believed God's word and was credited with righteousness.
This is kind of like having a credit card. The credit card is faith in what God says. Faith in God's word is believing in the Word. The Word is Jesus Christ. And Old Testament saints got the goods (i.e. heaven) beforehand. Then Jesus paid for their sins on the cross afterwards.
Even in the Old Testament, there was the concept of living by faith:
"But the righteous will live by his faith" (Habakkuk 2:4).
When Jesus came, during His transfiguration (which is a glimpse into heaven), Moses and Elijah appeared with Jesus.
"And behold, two men were talking with Him; and they were Moses and Elijah, who, appearing in glory, were speaking of His departure which He was about to accomplish at Jerusalem" (Luke 9:30-31).
Moses and Elijah appeared in glory even before Jesus died on the cross!
So Moses and Elijah were credited with righteousness beforehand. Old Testament saints were saved beforehand, and Jesus paid for everyone (past, present, and future).