i trying to make an % progress timer and i don’t know why it don’t work so well like look 24th of this month the timer started, and 28th ended but somewhy the % is 99 when its only started need help
Have you tried looking into os.time?
There’s ways to turn the time into an integer. Then, subtract the current time from when the timer started, and find out the difference between the two.
Then, you can figure out your target time, and subtract your begin time, to get the full amount of time need.
With these two numbers (current time - start time, goal time - start time) you can do some simple division (current / goal) to find out the float % of how far you are from your goal.
i tried
but look os.time() * 100 / enday
and it still don’t work i mean it is but its still like 99%
I don’t know what your code is, so idk exactly what you mean.
But, I made a simple tool to show you how this works. Add it to your game to try it out. It might help you better understand what you want.
TimeTracker60seconds.rbxm (1.2 KB)
It shows you four numbers in the Output when you use the tool. StartTime, Current Time, End Time, and the 4th number is the % of time that has passed since the Start and Current, with the goal being the End. (0.2333333333 would basically be 23%)
The example is using a time 60 seconds after the script is added as it’s end time (Basically, when the game starts, and then 60 seconds after that for the end)
but what if the end time is in days not in seconds.?
and like start day and end day the data
i just trying to do an live event with corruption bar
and its like -1% so its not working
tried to modify but didn’t worked
local day = os.time({year = 2021, month = 4,day = 28,hour = 0,min = 0,sec = 0})
script.Parent.Activated:Connect(function()
local CurrentTime = os.time()
local TimePercent = (CurrentTime - sday) / (day - sday)
print(sday, CurrentTime, day, TimePercent)
end)```
i didn’t meant what day it right now i meant the percentage of time spented between start of timer and end of timer
Are you using os.date? You would just change the %a to whatever you need to use. That was just an example.
If you’re trying to do this in days instead of seconds, you just convert with basic time conversion math.
60 seconds is in a minute. And 60 minutes are in an hour. And 24 hours are in a day. So if you want to make it 3 days, you would just do 3*60*60*24.
So if you want the end time to be 3 days after the start time, you just add that (3*60*60*24
) to the start time to get your end time.
but wait what if its not like when the script timer started working like as data? i used os.time() and added the data
Here. This might help:
EndTime = os.time{year = 2021, month = 4,day = 28,hour = 0,min = 0,sec = 0}
StartTime = os.time{year = 2021, month = 4,day = 25,hour = 0,min = 0,sec = 0}
script.Parent.Activated:Connect(function()
local CurrentTime = os.time()
local TimePercent = (CurrentTime - StartTime) / (EndTime - StartTime)
print(TimePercent)
end)
This sets the start time as the 25th, and then sets the end time for the 28th. When you use the tool, it checks the current time and gives you the % of time that has passed from the start to the end.
mmm so i should have just replace endtime with start time after (CurrentTime - StartTime),smart and it works doe thanks