How to make a countdown with miliseconds?

did you copy the script from pastebin

btw, if u use my script replace the player.PlayerGui with the surfacegui and remove the variable and game.player.playeradded thing completely

1 Like

yeah, I did. but as the devforums doesnt allow me to type anything less then thirthy characters i made this additional sentence to be able to communicate.

It’s probably a problem with one of the variables. May I see your output?

Here, please ignore some of the output. They are probably from the other scripts I am still working on.

can you also send a picture of your script?

here.

To do math in code is actually very easy.

Here is an example

local x = 12
local y = 4
print(tostring(x + y)) -- add
print(tostring(x - y)) -- takeaway
print(tostring(x * y)) -- multiply
print(tostring(x / y)) -- share

so you divide count by 60 to get the amount of time passed in minutes
and you multiple by 1000 to get miliseconds

I can help you since I have done this before

local RunService = game:GetService("RunService"); --Getting the "Run service"

local StartTick = tick(); --The starting tick
local TargetTime = 10; --Ten seconds
local CurrentTime = 0; --You can turn this into 00:00.00 format

RunService.Heartbeat:Connect(function() --Counting every heartbeat
	CurrentTime = (tick() - StartTick); --Setting the CurrentTime
	print(CurrentTime);
	if CurrentTime >= TargetTime then --Checking if CurrentTime reached the TargetTime
		print("Target time reached!");
	end
end)
What is tick()?

tick() is a variable that is counting the time elapsed since the start of the server.

you can preset the tick() to a variable and subtract that and get the time elapsed since the time you set the variable.

What is HeartBeat?

Basicaly the reflesh rate, like fps, but you can access it from the server and the client.
I don’t really understand how it works, but all you need to know is that Hearbeat get’s called super fast.

Also, remenber to keep it simple,
and try not to use a code you don’t understand(Unless it’s math, then I hate math so I’ll use it even if I don’t know why it works).

1 Like

bruh, i literally didnt do anything to the script and it started working again. So problem solved I guess. lol.

2 Likes

Hang on my one milisecond! It only works if I only test it by running or playing the game on server mode.

I have finally solved this, infact someone else literally used the script with the same issue. Here is the page where I found the solution incase you are wondering.