Let me say first, it basically works fully, but their is a minor error.
ServerScript (Inside ServerScriptService)
game.Players.PlayerAdded:connect(function(player)
local LastLogin = loginstore:GetAsync(player.userId)
if LastLogin then
local seconds = os.time() - LastLogin
local minutes = seconds/60
local hours = minutes/60
if hours >= 24 then
loginstore:SetAsync(player.userId, os.time())
end
else
loginstore:SetAsync(player.userId, os.time())
end
end)
ServerScript (Inside a TextLabel)
local rewardtime = 24*60*60
local loginstore = game:GetService("DataStoreService"):GetDataStore("LastLogin")
local player = script.Parent.Parent.Parent.Parent.Parent
local lastlogin = loginstore:GetAsync(player.userId) or os.time()
while true do
Seconds = rewardtime - (os.time() - lastlogin)
Minutes = Seconds/60
Hours = Minutes/60
script.Parent.Text = ("Daily Reward: d:d:d"):format(Hours,Minutes%(60),Seconds%(60))
wait(1)
end
Ok, so this works, as I said, with the whole counting down, etc. But if a Player joins and the hours is > 24 then it prints("Reward"), but the text at the bottom says "Daily Reward: -1:35:54" As you can see, it says -1, which is should be like "Daily Reward: 23:59:59" and then start to countdown.
When the player leaves and rejoins, it's working properly again, but I want it to say 23:59:59 and countdown when they get the reward.
Please help!
