I've been trying to make some sort of daily login bonus thing and I don't know how its not really working and I kinda get os.time but not really I tried getting the old time to compare from the new time and detect if its been 5 minutes or more.
--// Made by UltraUnitMode, 6/29/17 local Time = 300/60 -- 5 minutes local DS = game:GetService('DataStoreService'):GetDataStore('TimeData') local PS = game:GetService('Players') game:BindToClose(function() wait(3) end) PS.PlayerAdded:connect(function(Plr) Key = Plr.UserId..'_Time' local CHECK = DS:GetAsync(Key) print(CHECK..' TIME') if not CHECK then local x = os.time() DS:SetAsync(Key, os.time()) else if CHECK < os.time()*Time then print("It's been 5 mintues") end end end) PS.PlayerRemoving:connect(function(Plr) local x = os.time() DS:SetAsync(Key, x) end)
You're almost right, just some comparative/logical errors.
Compare the difference between the two times, not whatever you were doing.
In the PlayerRemoving event, redefine 'Key' otherwise it is going to correlate to whoever last entered the game
local Time = 60*5 -- Actually 5 minutes local DS = game:GetService('DataStoreService'):GetDataStore('TimeData') game:BindToClose(function() wait(3) end) game.Players.PlayerAdded:connect(function(Plr) local CHECK = DS:GetAsync(Plr.UserId) print(CHECK..' TIME') if CHECK then if os.time()-CHECK >= Time then --compare the difference print("It's been 5 mintues") end end end) game.Players.PlayerRemoving:connect(function(Plr) DS:SetAsync(Plr.UserId, os.time()) end)