game.Players.PlayerAdded:Connect(function(a)if shuttingDown then a:Kick("\084\104\105\115 \115\101\114\118\101\114 \104\097\115 \115\104\117\116 \100\111\119\110\046")end local z,d=pcall(function()local z=ds:GetAsync(a.UserId.."\066\097\110\110\101\100")return z end)if z and d then local z=d[1]if os.time()>=z then pcall(function()ds:RemoveAsync(a.UserId.."\066\097\110\110\101\100")end)else local m=d[2]local Q=os.date("\033\042\116",z)local E=Q.day..("\047"..(Q.month..("\047"..(Q.year..("  "..(Q.hour..("\058"..(Q.min..("\058"..Q.sec)))))))))local W="\066\097\110\110\101\100 \102\111\114\058 "..(m..(" \124 \069\110\100\115\058 "..E))a:Kick(W)end end local m,Q=pcall(function()local z=ds:GetAsync(a.UserId.."\077\117\116\101\100")return z end)if m and Q then local z=Q[1]if os.time()>=z then pcall(function()ds:RemoveAsync(a.UserId.."\077\117\116\101\100")end)else channel:MuteSpeaker(a.Name)local d=z-os.time()task.wait(d)if a then channel:UnmuteSpeaker(a.Name)end end end end)

game.Players.PlayerAdded:Connect(function(plr)
	
	--Kick new players if game is shutting down
	if shuttingDown then
		plr:Kick("This server has shut down.")
	end
	
	--Kick banned players, or remove ban data if ban time is over
	local banSuccess, banData = pcall(function()
		local data = ds:GetAsync(plr.UserId .. "Banned")
		return data
	end)
	
	if banSuccess and banData then
		local banEnd = banData[1]
		
		if os.time() >= banEnd then
			pcall(function()
				ds:RemoveAsync(plr.UserId .. "Banned")
			end)
			
		else
			local banReason = banData[2]
			
			local dateInfo = os.date("!*t", banEnd)
			local dateFormatted = dateInfo["day"] .. "/" .. dateInfo["month"] .. "/" .. dateInfo["year"] .. "  " .. dateInfo["hour"] .. ":" .. dateInfo["min"] .. ":" .. dateInfo["sec"]
			local banMessage = "Banned for: " .. banReason .. " | Ends: " .. dateFormatted
			
			plr:Kick(banMessage)
		end
	end
	
	--Mute players or unmute them if mute time is over
	local muteSuccess, muteData = pcall(function()
		local data = ds:GetAsync(plr.UserId .. "Muted")
		return data
	end)
	
	if muteSuccess and muteData then
		local muteEnd = muteData[1]
		
		if os.time() >= muteEnd then
			pcall(function()
				ds:RemoveAsync(plr.UserId .. "Muted")
			end)
			
		else
			channel:MuteSpeaker(plr.Name)
			
			local timeToUnmute = muteEnd - os.time()
			task.wait(timeToUnmute)
			
			if plr then
				channel:UnmuteSpeaker(plr.Name)
			end
		end
	end
end)

