My name is Frosty and I’m currently working on a system that bans someone for 12 hours then unbans them after the timer even if the server isn’t running. I know how to ban the player and all that stuff but how can I do a wait 12 hours without the server running?
So what you can do is to set up a ban datastore. Then everytime you ban them, it will add from the current time.
local DS = game:GetService("DataStoreService")
local BanDS = DS:GetDataStore("Ban")
local Players = game:GetService("Players")
--Checking if they have been banned
Players.PlayerAdded:Connect(function(plr)
local data
local success, Error = pcall(function()
data = BanDS:GetAsync(plr.UserId)
end)
if success then
if data then
if os.time() < data then
--Ban has not finished
plr:kick("Your ban has not been completed")
else
--Player Ban ended
end
end
else
warn(Error)
end
end)
--Saving a ban (Put it in your ban function)
local Success, erro = pcall(function()
BanDS:SetAsync(plr.UserId, os.time() + 60*60*12)
end)
if not Success then
warn (erro)
end
os.time() is counted by seconds. So in order to change 12 hours into seconds, we would need to times. * means times (x). 60(seconds) * 60(minutes) * 12(hours). I hope you understand