BCE0019: 'active' is not a member of 'SniperScarenewScript'.

I got this error in unity

Assets/Resources/NewScripts/WeaponManager.js(163,37): BCE0019: ‘active’ is not a member of ‘SniperScarenewScript’.

Here’s my code


//for sniper2005
if (weaponToSelect == 2 && zooming) {
	var SniperZoomin : SniperScarenewScript = weaponsInGame[2].gameObject.transform.GetComponent("SniperScarenewScript");
	if(SniperZoomin.active){
		SniperZoomin.sniperzoomin();
		zooming = false;
		}
}
else
	{
	var SniperZoomout : SniperScarenewScript = weaponsInGame[2].gameObject.transform.GetComponent("SniperScarenewScript");
	if(SniperZoomout.active){
		SniperZoomout.sniperzoomout();
		zooming = true;
		}

How to fix this error?

If this is checking the property/field from MonoBehaviour then try isActiveAndEnabled. If the field/property called active is part of custom class then go take a look to see if you’ve the spelling correctly, case is important if this is the case. Otherwise without showing the SniperScarenewScript class we can only guess what the issue really is.

I have a same problem. Our scripts all JS.

how can we add isActiveAndEnabled there? Thanks