This question has been solved.
You could save the time of their last login in datastore and then see how much time has passed.
local DataStore = game:GetService("DataStoreService"):GetDataStore("LastLogin") 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 (I cannot post the script here as the site breaks it............)
The script is for a GUI. You can change the wait time in the loop to change the update rate. Or you can remove the loop as it will update whenever the player dies.
Just put this in a script
inside a TextLabel
LastLogin
defaults to os.time()
in case the player has no value in DataStore. This should not happen because a value is assigned when a player joins the game for the first time but it does not hurt.
To find the TimeLeft
I subtract the time since the players last reward by 24. I find the TimeLeft
using the same method as before: subtracting from the current time and then dividing by 60 twice. It is just condensed into one statement instead of using multiple variables. Then I used some fancy string formatting and math to display the time left as a clock would.
Edits: Edited to not save when the player leaves :) Updated to show time in the correct format! Updated to show time in minutes and not a percentage Updated to be more efficient Updated to support Seconds
Locked by NinjoOnline, Spongocardo, and EzraNehemiah_TF2
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?