- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
CrilleStyles · Jun 03, 2014 at 02:50 PM ·
errormoneybce0020health
Wrong with script
I don't know how to fix this issue.
Assets/skripts/EnemyHealth.js(18,13): BCE0020: An instance of type 'moneySystem' is required to access non static member 'money'.
and this is my codes:
#pragma strict
var Health = 100;
function ApplyDammage (TheDammage : int)
{
Health -= TheDammage;
if(Health <= 0)
{
Dead();
}
}
function Dead()
{
Destroy (gameObject);
moneySystem.money += 100;//name of your script moneySystem
}
That is the enemy health script
var money : int = 1000;//amout of your money
var moneyText : GUIText;//To Display Your money
function Update()
{
if(money < 0)
{
money = 0;
}
}
And that is the moneySystem script
How do I fix this?
Comment
Best Answer
Answer by meat5000 · Jun 03, 2014 at 02:52 PM
Create a variable of type moneySystem and use GetComponent to link the moneySystem script you are trying to modify to your variable.
Your answer
![](https://koobas.hobune.stream/wayback/20220613150701im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Variable from other class always returns 0 1 Answer
Critical problem in importing scripts 3 Answers
what's wrong with this?? 2 Answers
Script Not Working? 2 Answers
Raycast Shoot Error 1 Answer