Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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 comment

1

You shouldn't be using tick due to the fact that tick is local. You should preferably use os.time

1 answer

I found this on the forums:

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

This discussion is preserved as it was. New answers, comments, and votes are closed.