Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make this check if the time passed is more then 24 hours but less then 48?

Asked by
RM0d 305 Moderation Voter
9 years ago
local TBP = 43200*2 

local store = game:GetService("DataStoreService"):GetDataStore("LastLogin")

function reward(p,unixData)

end

game.Players.PlayerAdded:connect(function(p)
local value = Instance.new("BoolValue",p)
value.Name = "newjoin"
value.Value = false
local tabx= store:GetAsync(p.Name) or {nil,0}
local h = Instance.new("Hint",nil)
tabx[1] = tabx[1] or 0 
tabx[2] = tabx[2] or 0

local lasttime = store:GetAsync(p.Name)
t = math.floor(tick())
local day= t-lasttime 
if day > TBP  then

    local dax = {t,tabx[2]+1}
store:SetAsync(p.Name,dax)

reward(p,dax)
else
    local seconds = TBP-(t-lasttime)
    local minutes =seconds/60
h.Text = "Come back in "..math.ceil(minutes).." minutes to receive a reward!"

end
end)

game.Players.PlayerRemoving:connect(function(p)
    if p.newjoin.Value == true then
    t = math.floor(tick())
    store:SetAsync(p.Name,{t,1})    
    end
end)
1
You shouldn't be using tick due to the fact that tick is local. You should preferably use os.time DigitalVeer 1473 — 9y

1 answer

Log in to vote
-1
Answered by 9 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

I found this on the forums:

 if math.floor(os.time()/(86400)) ~= prevDay
Ad

Answer this question