So below I have a script that creates a progress bar that increases at a speed by doing distance/Time. I also have a countdown timer aswell in a different script. One thing I noticed is that when I change <divide> to any other value, the bar is less accurate and is not synced with the countdown.
I am asking how I can make it accurate because I want to divide the numbers so it is a much smoother increase yet stay in sync with the timer. How can I fix this?
increase = 0 divide = 1 distance = 800 Time = 30 repeat wait(1/divide) increase = increase + (distance/Time)/divide script.Parent.Size = UDim2.new(0,increase,0,600) until increase >= distance - 10
Ah, it is just a simple error known as the roundoff error. Fix it by doing something like this and adding it to your script:
function Round(num) math.floor(num+0.5) return num end