How can I create a daily chest system?

Here’s a daily chest system I made a while ago. It doesn’t give money or anything but that should be simple to add into the script. Daily Chest - Roblox

That’s good but we’re also trying to teach him and not just supply him which is what the DevForum is about

Dissecting functional code is a great way to learn. He can look through it to see how I made mine and decide if he wants to use my design or create his own based on what he learns from my version.

1 Like

I know but explanation is also helpful too

os.time uses UTC so timezones won’t be a problem. Also, why not use os.time exclusively.

I would use os.time() along with a module script that contains every players last time they opened the chest. When they claim their reward you can check if enough time has passed. You can use a function like this:

local function GetTimeLeft(player, chestName)
	local startTime = chestTimes[player.UserId][chestName]
	if startTime then 
		local timePassed = os.time() - startTime
		local timeLeft = cooldown - timePassed
		
		return timeLeft
	elseif startTime == nil then
		return 0
	end
	return nil
end

Using a module script also allows your data store script to save it. To save data all you need to do is when they leave, save their section in the module script then remove it by setting it to nil.

Module would look something like:

chestTimes = {
    [UserId] = {
        DailyChest = 2343822
    }
}

I think the resources other people have sent, including you, are pretty good at explaining it. I’m just showing it to them in practice.

I looked through both the code and documentation and I seem to be getting a better understanding of os.time(). Thank you very much.

I’m glad it helped! Good luck with the rest of your project

My bad, you’re right! os.time would be fine then. Sorry for the confusion OP