How can I make my stop watch be MORE accurate?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m trying to make my game have a speed run aspect to it, so I made a stopwatch.
  2. What is the issue? Include screenshots / videos if possible!
    The issue is that it doesn’t calculate seconds correctly, for example it takes it multiple seconds to go up by one second
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to make the stop watch increase by 0.1 instead of 0.01 but I want it to have 2 digits after the decimal point instead of one.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
while IsPlaying == true do
			StopWatch.Value = StopWatch.Value + 0.01
			wait(0.01)
			end

if you want me to include the full script then just say below and i’ll give it to you.

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

You could use task.wait(0.01) instead wait(0.01). It’s better. Give it a try maybe?

1 Like

it became slightly more accurate but it still takes multiple seconds for it to go up by 1 second.

1 Like

Maybe use a custom wait() function instead? Here

1 Like
local CurrentValue = 0
while IsPlaying do
    CurrentValue += task.wait()
    StopWatch.Value = CurrentValue - CurrentValue % 0.01
end

Try this.

3 Likes

now it doesn’t even go up at all :confused:

1 Like
local val = 0
for i = 1, 10 do
    val += task.wait()
    print(val - val % 0.01)
end

the following code runs just fine. This feels like an issue with the UI part of your code, rather than this loop.

2 Likes

try

Value = 0
Time = os.time()
while wait() do
    Value = os.time() - Time
print(Value)
end

you might want to change the code
but if you use my code please click solved on my reply

1 Like

The script is in a server script. Not Ui.

1 Like

it actually worked when I made it so it says:

while IsPlaying == true do

instead of

while IsPlaying do

Tysm bro <3 !!!

1 Like