How to make a boosts for a limited time?

Hi,
I want to make a boost system in my game, but i don’t know how to make boosts be for a limited time.
i probably have to use os.time, but i don’t know how does this work. Can anyone show me some examples of os.time and i how i can use it. Also how could i display a time that left?

1 Like
local boostTime = 20

local startTime = os.time()

-- checking for boost to end 
wait(5)
local currentTime = os.time()
if (currentTime - startTime) >= boostTime then
-- handle 
end

Double check by printing that out it isn’t -5, I forgot which order the calculation should be.

2 Likes

Question, how long would you want boosts to last? If you are going for boosts that last for like a day, I’ve posted how to do a daily reward system in this post What's Wrong With My Hourly Chest System? - #6 by kingerman88
You can modify that code to your needs

1 Like

How can i display the time? when im trying to print time it says random code

1 Like

oh nevermind i found something in internet

1 Like

For anyone else wondering;

os.time() returns the exact seconds from the epoch, tick() does the same and is more accurate. I forgot which one is local to a players machine.

2 Likes