Hi guys! My login bonus awards players if they have come back after 24 hours or more, however the countdown gets messed up. For example, after the 24 hours is up it starts doing minus hours (For example, "-47:30:29")
Any ideas? Thanks.
Main Script in Workspace:
local DataStore = game:GetService("DataStoreService"):GetDataStore("LoggedIn")
Game.Players.PlayerAdded:connect(function(Player)
wait()
local LastLogin = DataStore:GetAsync(Player.userId)
if LastLogin then
local Seconds = os.time()-LastLogin
local Minutes = Seconds/60
local Hours = Minutes/60
print("It has been: "..Hours.." hours Since your last reward")
if Hours >= 24 then
print("You get a daily login award")
DataStore:SetAsync(Player.userId,os.time())
end
else
DataStore:SetAsync(Player.userId,os.time())
end
end)
Script in TextLabel:
local RewardTime = 24*60*60
local DataStore = game:GetService("DataStoreService"):GetDataStore("LoggedIn")
local Player = script.Parent.Parent.Parent.Parent
local LastLogin = DataStore:GetAsync(Player.userId) or os.time()
while true do
Seconds = RewardTime-(os.time()-LastLogin);
Minutes = Seconds/60;
Hours = Minutes/60;
script.Parent.Text = ("Time Until Next Reward: d:d:d"):format(Hours,Minutes%(60),Seconds%(60))
wait(1)
end

10 comments
Thank you very much, but it just says "Time until next reward:d:d:d" Any ideas? :D :D Thanks!
You need a percentage symbol before each of the d's. Edited my answer.
This is still not working :/ Any ideas?
Edited answer.
Thanks so much! I will check it out! :)
btw, when the time has elapsed, I just want it to count down another 24 hours - not go to 0:00:00 - because at the moment it is going to minus something. I hope this works! :D
If you want to do that, for the else bit, just give them the reward you want and then just re-set LastLogin instead of going to 00:00:00.
To do that (reset it) would I do this local LastLogin = DataStore:GetAsync(Player.userId) or os.time() under the else?
(I am already awarding the points in the main script in the workspace, so that is fine!)
You could just do local LastLogin = os.time() and then save it if you want.