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.
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
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)
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.
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