When i play the game i got this error, how i can solve that?
Code:
SwichWeapons changeWeapon;
void Start()
{
changeWeapon = GameObject.FindWithTag(playerTag).GetComponent<SwichWeapons>() as SwichWeapons;
}
void Update()
{
changeWeapon.GetComponent<SwichWeapons>().DefaultWeaponVoid();
}
Full Code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using CodeStage.AntiCheat.ObscuredTypes;
public class WeaponShop : MonoBehaviour
{
[Header("-Tags-")]
public ObscuredString playerTag = "Player";
[Header("-Weapon Settings 01-")]
public Button WeaponButton1;
public ObscuredInt WeaponPrice1 = 5000;
public ObscuredInt LevelForWeapon1 = 5;
public Text weaponPriceText1;
public GameObject blockedPannel;
public Text levelTextPermison;
[Header("-Weapons Boolen Options-")]
[SerializeField]
private ObscuredBool weaponPsitol = true;
[SerializeField]
private ObscuredBool weaponAssaultRifle = false;
SwichWeapons changeWeapon;
void Start()
{
changeWeapon = GameObject.FindWithTag(playerTag).GetComponent<SwichWeapons>() as SwichWeapons;
WeaponButton1.interactable = false;
weaponPsitol = true;
weaponAssaultRifle = false;
weaponPriceText1.text = WeaponPrice1.ToString();
}
void Update()
{
if(UpgradeMenu.Money >= WeaponPrice1)
{
WeaponButton1.interactable = true;
}
else
{
WeaponButton1.interactable = false;
}
if(LevelSystem.PlayerLevel < LevelForWeapon1)
{
blockedPannel.SetActive(true);
levelTextPermison.text = "You don't have level " + LevelForWeapon1;
}
else if(LevelSystem.PlayerLevel >= LevelForWeapon1)
{
blockedPannel.SetActive(false);
}
if(weaponPsitol == true && weaponAssaultRifle == false)
{
changeWeapon.GetComponent<SwichWeapons>().DefaultWeaponVoid();
weaponPriceText1.text = WeaponPrice1.ToString();
}
if (weaponAssaultRifle == true && weaponPsitol == false)
{
changeWeapon.GetComponent<SwichWeapons>().weapon01Void();
weaponPriceText1.text = "Owned";
}
}
public void BuyWeapon01()
{
if (LevelSystem.PlayerLevel >= LevelForWeapon1)
{
if (UpgradeMenu.Money >= WeaponPrice1)
{
weaponAssaultRifle = true;
weaponPsitol = false;
UpgradeMenu.Money -= WeaponPrice1;
}
}
}
}