Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Waiting .025 seconds actually waiting .03?

Asked by 5 years ago

I have a little bar in my frame, and every .025 seconds, I expand it by 1% of the screen's width. I do this 40 times, so it should take 40 seconds. Here's the code:

local start = tick()
for i = 1, 40 do
    if hasReleased then break end

    gui.Frame.Bar.Size = UDim2.new(gui.Frame.Bar.Size.X.Scale + 0.01, 0, 0.1, 0)
    gui.Frame.Bar.Transparency = 0
    wait(.025)

    print(tick() - start)
end

But each time it prints, instead of increasing by .025, it seems to wait around .03 seconds:

Image

In case it matters, my Roblox Studio default wait() time is 0.010000000000000000208 aka 0.01

0
It's only a 0.05 second difference, it isn't that obvious User#19524 175 — 5y
0
Roblox's minimum wait is always going to be 0.029999..., I presume. RAYAN1565 691 — 5y
0
It's pretty obvious when I tell my users to wait for 1 second and ends up waiting for 1.333333 seconds. Zenith_Lord 93 — 5y
0
But we're talking a 0.05 second difference. User#19524 175 — 5y
View all comments (8 more)
0
OMG it adds up when I'm trying to wait 1 second... Zenith_Lord 93 — 5y
0
Plus I get really OCD when it doesn't add up exactly to 1 second. Zenith_Lord 93 — 5y
0
then do .2 LOL greatneil80 2647 — 5y
0
what? Zenith_Lord 93 — 5y
0
Don't do countdowns like this; do starttime - currenttime to get elapsed time because that doesn't suffer from delays like this thebayou 441 — 5y
0
Could you elaborate? Zenith_Lord 93 — 5y
0
Roblox are Updating on 1/30 seconds, you can't do the third decimal place. Mitumitu17YN -5 — 5y

Answer this question