I have got a problem with my temp ban system - I have done the first bit which is setting the ban which works fine but the problem is then the player then joins again in which it works for the player banned fine.
Here is the code - (its in ServerScriptServcie)
local ds = game:GetService('DataStoreService') local banData = ds:GetDataStore('BanData') local admin = {'CRAZYQUACKY84'} local banTimes = { one_Day = 86400; three_Days = 259200; one_Week = 604800; } game.Players.PlayerAdded:Connect(function(player) local Success, Result = pcall(function() return banData:GetAsync(tostring(player.UserId), 'BanData') end) if Success then if Result then if Result.BST + Result.BT > os.time() then warn('Ban is done') banData:RemoveAsync(player.UserId) else player:Kick('\n You are temporarily banned for violating Terms of Service.') end end end end) game.Players.PlayerAdded:Connect(function(plr) for _,v in pairs(admin) do if plr.Name == v then plr.Chatted:Connect(function(ban) local args = ban:split(' ') if args[1] == ':ban' then local plrToBan = game.Players:FindFirstChild(args[2]) local banReason = args[3] local plrInputBan = args[4] if plrToBan then local Success, Error = pcall(function() if plrInputBan == 'one_day' then banData:SetAsync(tostring(plrToBan.UserId),{BST= os.time(), BT = banTimes.one_Day}) plrToBan:Kick('\n You have been banned for 1 day. \n Enforcer: '..plr.Name..'\n Reason: '..banReason) elseif plrInputBan == 'three_day' then banData:SetAsync(tostring(plrToBan.UserId),{BSTe = os.time(), BT = banTimes.three_Days}) plrToBan:Kick('\n You have been banned for 3 days. \n Enforcer: '..plr.Name..'\n Reason: '..banReason) elseif plrInputBan == 'one_week' then banData:SetAsync(tostring(plrToBan.UserId),{BST = os.time(), BT = banTimes.one_Week}) plrToBan:Kick('\n You have been banned for 1 week. \n Enforcer: '..plr.Name..'\n Reason: '..banReason) end end) if not Success then warn('Not Successful.') end end end end) end end end)
BST = BanStartTime BT = BanTime