C# QualitySettings.antiAliasing Black Screen

Hi everyone, I’m having a problem with controlling QualitySettings.antiAliasing. I’ve tied it to a horizontal slider but for some reason when I use the slider the screen goes black. Any ideas what is wrong?

    public int antiAliasingInt;	
    
    antiAliasingInt = Mathf.RoundToInt(GUILayout.HorizontalSlider(antiAliasingInt, 0, 8,GUILayout.Width(150), GUILayout.Height(35)));
    QualitySettings.antiAliasing = Mathf.RoundToInt(antiAliasingInt);

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour 
{
	public int[] antiAliasingInt;
	int slider;
	
	void Awake()
	{
		antiAliasingInt = new int[]{2, 4, 6, 8};
	}
	
	void Update()
	{
		foreach(int i in antiAliasingInt)
		{
			if(slider == i)
				QualitySettings.antiAliasing = i;
		}
	}
	
	void OnGUI()
	{
		slider = (int)GUILayout.HorizontalSlider(slider, 0, 8,GUILayout.Width(150), GUILayout.Height(35));
	}
}