I read the page for os time and I wonder if I could make a bonus like give the player points every time they play every day.
I think it should work like this:
game.Players.PlayerAdded:connect(function(player) if player:WaitForDataReady() and player:LoadNumber("TimeSinceLastOn") < os.time(day) then player.leaderstats.Points = player.leaderstats.Points +10 end end) game.PlayerRemoving:connect(function(player) player:SaveNumber("TimeSinceLastOn", os.time(day)) end) game.OnClose:connect(function() wait(30) end) --Am I close? How would I do this for hours, years, minutes, or seconds even?
So would this work as a ban script?
game.Players.PlayerAdded:connect(function(plyr) local banned = false if plyr:WaitForDataReady() and plyr:LoadNumber("BanTimeLeft") >= 0 then print(plyr.Name..", don't curse again.") elseif plyr:LoadBoolean("IsBanned") and BanIfCurse then Instance.new("Message", plyr).Text = "You're banned for cursing. You may play again after: "..plyr:LoadNumber("BanTimeLeft") end plyr.CharacterAdded:connect(function(char) plyr.Chatted:connect(function(chat, chatter) if chat == "[Content Deleted]" and BanIfCurse then plyr:SaveBoolean("IsBanned", true) plyr:SaveBoolean("BanTimeLeft", BanTime) plyr:Kick() else end end) end) end)
day
isn't defined, so using that wouldn't make sense.
os.time()
returns number of seconds; a day is 60 * 60 * 24
seconds.
Besides that, your script is missing something. You will punish players for coming back more often than every 24 hours, since every time they leave, the time is reset.
Instead, reset the time when they get their reward.
function join(player) if player:WaitForDataReady() then local nextReward = player:LoadNumber("NextReward") local newPlayer = nextReward == 0 -- local now = os.clock() -- if now is before next reward time (or they are a new player) if now <= nextReward or newPlayer then -- <Give reward here> local tomorrow = now + 60 * 60 * 24 -- now plus a day player:SaveNumber("NextReward", tomorrow ) end end end
It's very very similar for identifying someone for, say, a day:
local banTime = 60 * 60 * 24 -- one day function ban(player) local now = os.clock() -- They are banned until now plus one day player:SaveNumber("BannedUntil", now + banTime) player:Kick() end function join(player) player:WaitForDataReady() local now = os.clock() if now < player:LoadNumber("BannedUntil") then -- now is before ban ends? player:Kick() end end