the goal of this script is after 12 hours a player receives a reward, the problem is that the while true do loop only cycles once
local RewardTime = 12*60*60
local DataStore = game:GetService("DataStoreService"):GetDataStore("LastLogin")
local Player = script.Parent.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)
DataStore:SetAsync(Player.userId,os.time())
end
Thanks

6 comments
Check your output before you post here. If a while true do loop only works once, it errors somewhere.
no error output tho
It's most likely because you're sending a SET request to data store every one second (which you should not be doing), therefore the request get's throttled. Since every request in data store yields, your loop won't recycle until the request is done throttling (which can be a very long time)
Actually, let me change that "most likely" to "most certainly", because that is the problem. I'll write an answer because this can be tricky to explain to someone who isn't that familiar with the limitations of data store.
is there a better way to save it without it being in the loop?
Don't worry, I'm working on an explanation.