oh well it is how many day passed since 1970 june 01 thing I think it is a great way to get day
i tried it earlier with 86400 because i wanted to add daily rewards into my game but it didn’t work even when i was saving the data so i had to change it to the -86400 one
1 Like
Don’t worry about it. I set the value at DataStoreService script as 0
Yeah removing gives an error: : field ‘day’ missing in date table
local TIME_DATA
local DataStoreService = game:GetService('DataStoreService')
local TimeDataStore = DataStoreService:GetDataStore('TIME_DATA')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Players = game:GetService('Players')
local WingsDataStore = DataStoreService:GetDataStore('WINGS_DATA')
Players.PlayerAdded:Connect(function(player)
local AngelWings = Instance.new('IntValue')
AngelWings.Parent = player
AngelWings.Name = 'AngelWings'
local WINGS_DATA
local success, err = pcall(function()
WINGS_DATA = WingsDataStore:GetAsync(player.UserId..'WINGS')
TIME_DATA = TimeDataStore:GetAsync(player.UserId..'TIME')
end)
local OpenDailyReward = ReplicatedStorage:WaitForChild('OpenDailyReward')
if success then
AngelWings.Value = WINGS_DATA
if TIME_DATA ~= nil then
if tonumber(TIME_DATA) < os.time() - 86400 then
local ClaimReward
ClaimReward = ReplicatedStorage:WaitForChild('ClaimDailyReward').OnServerEvent:Connect(function(FoundPlayer)
if FoundPlayer == player then
print('player has claimed daily reward.')
TimeDataStore:SetAsync(player.UserId.. 'TIME', os.time())
OpenDailyReward:FireClient(player, player)
local randomWeight = math.random(100)
if randomWeight > 0 and randomWeight < 11 then
AngelWings.Value += 15
elseif randomWeight >= 11 and randomWeight < 26 then
AngelWings.Value += 10
elseif randomWeight >= 26 and randomWeight < 101 then
AngelWings.Value += 5
end
ClaimReward:Disconnect()
end
end)
end
else
print('New player found')
local ClaimReward
ClaimReward = ReplicatedStorage:WaitForChild('ClaimDailyReward').OnServerEvent:Connect(function(FoundPlayer)
if FoundPlayer == player then
print('player has claimed daily reward.')
OpenDailyReward:FireClient(player, player)
TimeDataStore:SetAsync(player.UserId.. 'TIME', os.time())
local randomWeight = math.random(100)
if randomWeight > 0 and randomWeight < 11 then
AngelWings.Value += 15
elseif randomWeight >= 11 and randomWeight < 26 then
AngelWings.Value += 10
elseif randomWeight >= 26 and randomWeight < 101 then
AngelWings.Value += 5
end
ClaimReward:Disconnect()
end
end)
end
end
if err then
error(err)
end
end)
This is what I did for my daily reward you may have to adjust or change some things though. Also it doesn’t start at 1:00
1 Like
Also I doubt it would be possible to do 1:00-25:00 with os.time() since 86400/3600 is for a single day and it accounts for every day since 1970
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.