Basically I have a GUI which counts down, but when it gets to below 1 (it counts down in 0.1 every 10th of a second) it starts saying like "0.099999999999999". How can i fix this?
Here's the code:
for i=15,0,-0.1 do script.Parent.Text = i wait(0.1) end
I've had this problem too, except with transparency. Here is what I did.
for i = 0, 1.5, 0.1 do --Start a For loop that goes from 0 to 1.5 using a 0.1 step. x = i-1 --If it doesn't work try 1-i --Reverse the number using a variable script.Parent.Text = x*10 --Instead of i, use the new variable, x and multiply it by 10 to get an integer. wait(1) --wait one second. end --end the for loop
Make the GUI use math.floor or math.ceiling. They round up the number to the bottom or top, respectively. Example:
script.Parent.Text = math.floor(i)
you need to set a Value for it to finish at(Use this code)
wait(10) timer = Instance.new("ScreenGui") timer.Name = "countdown" timer.Parent = game.StarterGui frame = Instance.new("TextLabel", timer) frame.Name = "value" frame.Position = UDim2.new(0, 0, 0) --Then create two int values on starter and one finish svalue = Instance.new("IntValue", frame) svalue.Name = "start" svalue.Value = 0 evalue = Instance.new("IntValue", frame) evalue.Name = "end" evalue.Value = 0 --Here comes he code you can change it to your specs wait(10) frame.Text = svalue.Value -1 if svalue.Value <= evalue.Value then frame:remove() end