Hi there! I was trying to create a daily reward chest and it works, but there is 1 problem, when a player logs off I want the time to save when they’re offline. I’m currently using Data Store 2 and Nothing has really worked. Here is some code that I tried:
local NotifyDaily = game:GetService("ReplicatedStorage").NotifyDaily
game.Players.PlayerAdded:Connect(function(plr)
local timeNow = os.time()
if plr:WaitForChild("stats").DailyRewardTimer ~= nil then
local lastClaimed = timeNow - plr.stats.DailyRewardTimer.Value
print("Time since last claimed " .. lastClaimed)
if (lastClaimed / 3600) >= hourWait then
plr.stats.DailyRewardTimer.Value = 0
NotifyDaily:FireClient(plr)
end
end
end)
The printing statement gives me a huge number something like 460k. I tried that because I want it to convert to hours.