Ugh, I've been trying to solve for a long time now. I thought I fixed this issue. But I didn't. This is a daily rewards script. It worked when I first joined the game with no saved time value. It gave me the reward pack. But when I checked the frame to see when my next reward was, it was blank. 00:00:00. The time text updater works fine, it's not that. I rejoined the game to see that the next reward was coming in like 00:01:47.. What in the world? Please help me fix :(
local ds = game:GetService("DataStoreService"):GetDataStore("DXD")
local function GiveDailyReward(plr)
local p = game.ReplicatedStorage.GUIs.DailyRewardPack:Clone()
p.Parent = plr:WaitForChild("PlayerGui")
end
game.Players.PlayerAdded:connect(function(p)
wait(1.5)
local g = ds:GetAsync(p.userId)
local t = Instance.new("NumberValue",p)
t.Name = "Time"
if g then
local diff = (os.time() - g)
if diff > 86400 then
ds:SetAsync(p.userId,os.time())
elseif diff > 43200 then
GiveDailyReward(p)
ds:SetAsync(p.userId,os.time())
end
else
GiveDailyReward(p)
ds:SetAsync(p.userId,os.time())
end
wait(.5)
t.Value = (os.time() - ds:GetAsync(p.userId))
end) |