How would i fix this?

I have created a countdown script that subtracts 0.025 each time. but the numbers are way too log for some odd reason

image

while true do
	for i = 10,0,-0.0025 do
		
		wait(0.01)
		
		print(i)
		
		script.Parent.Text = i
		
	end
end

It’s a thing called floating point errors.
More info on them:

You can just increase your numbers and divide afterwards.

New code:

while true do
	for i = 10000, 0, -25 do
		task.wait(0.01)
		
		i /= 1000
		print(i)
	end
end

This is likely due to precision errors, you can do this as an alternative:

script.Parent.Text = string.format("%.2f", i)

or what @Katrist suggested

1 Like