I am trying to make a login bonus award system like in The Mad Murderer. I erased all script but I want it to use os.time() and datastores. Please tell me how I would do this.
What you need to do is use os.time() with DataStores. When players leave, save a key with the os.time() and when players enter then check if there's any data saved. If there is then compare the saved data with the current os.time() to check time differentiation.
Why should you use os.time rather than tick? Because tick() is localized to the client's console, meaning that the time can be altered by either the client logging on from a different time zone OR changing the system's time settings and exploiting your daily award system. os.time returns a time that is same between all consoles, so these little methods are no longer possible.
Example;
local ds = game:GetService('DataStoreService'):GetDataStore('DailyRewards') local dayMin = 60*60*24 local dayMax = 60*60*24*2 --The daily time areas.. Between 24 hours and 42 game.Players.PlayerAdded:connect(function(plr) local key = tostring(plr.userId).."_time" local data = (os.time() - ds:GetAsync(key)) or 0 if data >= dayMin and data <= dayMax then print('Award player here') end end game.Players.PlayerRemoving:connect(function(plr) local key = tostring(plr.userId).."_time" local data = ds:GetAsync(key) if data then ds:UpdateAsync(key,function(old) return os.time() end) else ds:SetAsync(key,os.time()) end end)
I also suggest looking into game.OnClose in order for safe game crashes and the ability to shutdown all servers when you want to update.