When we, those of us who have accepted Jesus as our Lord and Savior, sin, we have thought, spoken, or acted according to our will, as opposed to living according to God's will. Immediately, the Holy Spirit begins convicting us of our sin, and unless we repent and confess our sin, the Father disciplines us (Heb. 12:5-12; 1 Jn. 1:9).
An example of the Lord's discipline is found in 1 Corinthians 11:23-32. Notice that there is a progression of severity in God's disciplining of His errant child: weakness, sickness, and finally, death (v. 30). The writer of the Hebrews passage had subtly suggested that rebellion could result in the physical death of a believer. He wrote, ". . . shall we not much rather be in subjection unto the Father of spirits, and live? (v. 9). However, for the child of God, death does not mean one loses his or her salvation, but that God, not wanting His Son's name tarnished by the believer, removes His child (1 Cor. 5:4-5).
On the other hand, an unbeliever may repent of his sin, and even try to compensate for it by doing good works. After Jesus had fed the 5000, He had to rebuke them for following Him for selfish reasons (Jn. 6:1-27). They were repentant and "Then said they unto Him, What shall we do, that we might work the works of God? Jesus answered and said unto them, This is the work of God, that ye believe on Him (Jesus) whom He (the Father) hath sent" (Jn. 6:28-29). He continued teaching, and in the end, all but the twelve ceased to follow Him (Jn. 6:30-71). They had repented but failed to believe!
Salvation results from turning from one's sin and trusting in the sinless One: Jesus!