Can anyone help me with this error? BCE0120: 'MouseLook.rotationY' is inaccessible due to its protection level.

I’ve been working on a game for a few days now, and It’s been working perfectly fine, but just recently I had saved the games progress and closed out of unity. After coming back to work on the game some more It started giving me this error.

Assets/GunScript.js(156,91): BCE0120: ‘MouseLook.rotationY’ is inaccessible
due to its protection level.

I don’t know why this error just popped up because the game was working perfectly before I reopened it. There were no errors before I saved and closed out but then I started getting the one mentioned above right after restarting Unity. Does anyone know why this is happening? My MouseLook Script is public so I don’t see how that’s the problem. But here is my GunScript just incase it really is something to do with that.

var RotationSpeed : float;
var PlayerCamera : GameObject;
var IsAiming : boolean = false;
var GunAnimationHolder : GameObject;

//Targets
@HideInInspector
public static var TargetXrotation : float;

@HideInInspector
public static var TargetYrotation : float;

@HideInInspector
public static var TargetXrotationV : float;

@HideInInspector
public static var TargetYrotationV : float;

// Gun Specs
var MaxClipSize : float = 10;
public static var AmmoInCurrentClip : float = 10;
var ExtraAmmo : float = 20;
var MaxCarringAmmo : float = 256;

//  Bullets and shiz
var Bullet : GameObject;
var BulletSpawn : GameObject;
var BulletSound : GameObject;
var FireRate : float;
var FireTimer : float;

//Recoil
var Recoil : float = 3;
var RecoilAimingIn : float = 3;
var RecoilAimingOut : float = 6;

//Reloads
var ReloadAnimation : GameObject;
var ReloadSound : GameObject;
var Reloading : boolean = false;
var ReloadName : String;




function Update()
{
	AimingInController();
}

function AimingInController()
{
	IsAiming = GunAnimationHolder.GetComponent(Player).AimingIn;
}

function LateUpdate () 
{

if (AmmoInCurrentClip > MaxClipSize)

AmmoInCurrentClip = MaxClipSize;

if (ExtraAmmo > MaxCarringAmmo)

ExtraAmmo = MaxCarringAmmo;

if (FireTimer < -5)
FireTimer = -5;

if (MaxClipSize < 0)

MaxClipSize = 0;

if (AmmoInCurrentClip < 0)

AmmoInCurrentClip = 0;

if (!Reloading && AmmoInCurrentClip < MaxClipSize && ExtraAmmo > 0 && Input.GetButtonDown("Reload")&& IsAiming == false)
	{
		Reloading = true;
		ReloadSound.Play();
		ReloadAnimation.animation.Play("Reload");
	}
	
if (!Reloading && AmmoInCurrentClip == 0 && ExtraAmmo > 0 && Input.GetButtonDown("Fire1") && IsAiming == false)
	{
		Reloading = true;
		ReloadSound.Play();
		ReloadAnimation.animation.Play("Reload");
	}
	
if (Reloading && !ReloadAnimation.animation.IsPlaying(ReloadName))
{
	if (ExtraAmmo >= MaxClipSize - AmmoInCurrentClip)
	{
	ExtraAmmo -= MaxClipSize - AmmoInCurrentClip;
	AmmoInCurrentClip = MaxClipSize;
	}
	
	if (ExtraAmmo < MaxClipSize - AmmoInCurrentClip)
	{
		AmmoInCurrentClip += ExtraAmmo;
		ExtraAmmo = 0;
	}
Reloading = false;
}

var MyBulletSound : GameObject;

if (Input.GetButton("Fire1") && AmmoInCurrentClip > 0 && !Reloading)
{

	if (FireTimer <= 0)
	{
AmmoInCurrentClip -= 1;

TargetXrotation += (Random.value - 0.5) *Mathf.Lerp (Recoil, RecoilAimingOut,0);
TargetYrotation += (Random.value - 0.5) *Mathf.Lerp (Recoil, RecoilAimingOut,0);


		if (Bullet)
		{
		Instantiate(Bullet,BulletSpawn.transform.position,BulletSpawn.transform.rotation);
		}
		
		if (BulletSound)
		{
		MyBulletSound = Instantiate(BulletSound,BulletSpawn.transform.position,BulletSpawn.transform.rotation);
		}
		
	FireTimer = 1;
	}


}

if (Input.GetButton("Fire2") && !Reloading )
{
	Recoil = RecoilAimingIn;

}

if (Input.GetButton("Fire2") == false || Reloading )
{
	Recoil = RecoilAimingOut;

}


FireTimer -= Time.deltaTime * FireRate;

transform.position = PlayerCamera.transform.position + (Quaternion.Euler(0,TargetYrotation,0)* Quaternion.Euler(TargetXrotation,TargetYrotation,0) * Vector3(0,0,0));

TargetXrotation = Mathf.SmoothDamp(TargetXrotation, -PlayerCamera.GetComponent(MouseLook).rotationY,TargetXrotationV,RotationSpeed);

TargetYrotation = Mathf.SmoothDamp(TargetYrotation, PlayerCamera.GetComponent(MouseLook).RotationX,TargetYrotationV,RotationSpeed);

transform.rotation = Quaternion.Euler(TargetXrotation,TargetYrotation,0);


}

In C#, instance variables are private by default. If you look at the MouseLook script you will see rotationY declared:

float rotationY = 0F;

To access it you will need to make it public:

public float rotationY = 0F;

Note this is different than Javascript/Unityscript where variables are public by default and must be explicitly set to ‘private’.