Yesss. Finally. You're absolutely right, it should be placed at the Setting Up part. I guess I was still thinking in GUI.
I did this and it gave me the right number all the time, then I applied this into a score board and that too took me a while to get right since I didn't know exactly where to Call the function.
Anyway, long story short, problems solved AND every other functions I wanted to do is also achieved thanks to your tips. I wish I could +1 you more mate.