How to make a countdown with miliseconds?

Hello everyone, here I am again… do I really need to explain… like its pretty obvious. A countdown with minutes, seconds and miliseconds on a text label.

Although I couldnt find any resources on how to do this, any help would be appriciated.

What I want to do is:

10 minute countdown
And it goes down, simple.

Cheers.

Note: I am still a rookie, please try to provide some sort of explanation, tutorial or sample if you can. I dont get advanced scripter terms yet.

2 Likes

Like time will counts down each 1 second passed?
Also you need to show your script for help easier

2 Likes

I did this post because I DONT KNOW how to do the script in the first place.

1 Like

Oh, so i will help you doing that! (even im enjoying my meal)

local text = Where_Your_TextLabel_Is
local Time = script.Parent.TimeRemain --Add a new Int Value in the textlabel
Time.Value = How_Much_Time_You_Want

IsCounting = false

wait(1)
IsCounting = true
Time.Value = Time.Value - 1 --this time value will minus 1 after 1 second is passed
if Time.Value <= 0 then
IsCounting = false
end
Repeat
Text.Text = Time.Value
Until IsCounting = false

Tell me if something wrong happens

2 Likes

Alright, so since a millisecond is a thousandth of a second as shown here:

1 divided by 1000 is 0.001 so we wait by 0.001

1 Like

This wasnt what I was trying to do, I want it to look like MINUTES:SECONDS:MILISECONDS.

Oh… Let me take some times to fix it after im done my meal :curry:

1 Like

-.-

2 Likes

Unfortunately it’s not really possible to count down in exact milliseconds. Roblox is limited at 60 fps without a FPR unlocker so you can count down in about 17 ms.

The script is very easy though. You can use the stepped Event on Runservice to do this very easily.

local count = 0
RunService.RenderStepped:Connect(function(dt)
    count += dt
    --To convert to miliseconds multiply by 1000
    -- To get minutes divide by 60
end)

WAIT DIDNT SEEN THE FULL SCRIPT! Sorry.

I dont really get it. Is this meant to work if someone steps on it?(Which I dont I want it to work like that)

What do you mean? Someone steps on it?

I thought that was what stepped event meant, I am still a rookie which I explained at the post.

Okay. Stepped means the next frame is here.

RenderStepped means the next Render frame has just started. What it does is run the function every frame. It adds the time from the last frame onto the count. The count is how long the clock has started in seconds

For you to test go into Roblox studio use that code and print(count) at the end.

Welll…

what do I do here?

--To convert to miliseconds multiply by 1000
-- To get minutes divide by 60

what am I meant to place?

maybe do this?

local player
game.Players.PlayerAdded:Connect(function(plr)
         player = plr
end)

local count = 3

local countString = "100"

local canCount = true

while task.wait(1/1000) do
	if canCount == true then
		if count <= 0 then
			count = 0
			canCount = false
		else
			count -= 0.01
		end
		player.PlayerGui.TextLabel.Text = tostring(count)
	end
end

Since math in roblox is kinda weird, it will do 4.970000blahblahthsiisanintnotastringlol

2 Likes

This doesnt help for this one simple reason, I am doing this on a SURFACEGUI not a SCREENGUI

btw, ignore count string its a test

I do not think there is a difference between using either. one is just for parts, while the other is used for screens.

I tried placing the scipt on surface gui, it didnt work.