- Home /
What Am I Doing Wrong?
Hey, thanks for helping... I'm having a few basic problems, and I can't seem to find anything on the internet about it.
I have a script here, in JS, which is using some things I found on the internet, and others from previous (working) scripts.
I'm getting three errors: BCE0043: (16,17) Unexpected token: if BCE0043: (16,21) Unexpected token: Win BCE0044: (18,45) expecting : , found =
Script:
#pragma strict
var score : int = 10;
var health : int = 15;
var Win : int;
Win = (Random.Range(1, 2));
var oldscore;
var oldhealth;
function Update ()
{
if (Input.GetButtonDown("Fire2"))
oldscore = Melee.score;
oldhealth = Melee.health;
{
if (Win = 1);
{
Melee.score = oldscore + score;
}
if Win = 2;
{
if ((Melee.health + health) = <=100)
{
Melee.health = oldhealth + health;
}
else
{
null;
}
Destroy (gameObject);
}
}
}
Thanks for your help!
Answer by Lovrenc · Jul 28, 2013 at 09:20 AM
if (Win = 1);
Should be
if (Win == 1)
if Win = 2;
Should be
if (Win == 2)
etc.
if ((Melee.health + health) <= 100)
Thanks for the help...howver now I get these problems...
Script: #pragma strict
var score : int = 10;
var health : int = 15;
var Win : int;
Win = (Random.Range(1, 2));
var oldscore;
var oldhealth;
function Update ()
{
if (Input.GetButtonDown("Fire2"))
oldscore = $$anonymous$$elee.score;
oldhealth = $$anonymous$$elee.health;
{
if (Win == 1)
{
$$anonymous$$elee.score == oldscore + score;
}
if (Win == 2)
{
if (($$anonymous$$elee.health + health) <=100)
{
$$anonymous$$elee.health = oldhealth + health;
}
else
{
null;
}
Destroy (gameObject);
}
}
}
Please do a few scripting tutorials, this code is full of mistakes and improperly formatted. You cannot come here everytime you need to write a script and have it done for you.
Sorry, I was a bit annoyed when I posted the second script. Believe it or not, I have done a few tutorials...a lot of the stuff Unity was confused about was based off a few errors I had made, which it then suggested solutions for...simply put having done all the solutions Unity had suggested I didn't understand the code any more. I've now rewritten and I think I have it done. Thanks
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can Someone help me with a script? (2D) 0 Answers
Script suddenly stopped working properly 1 Answer
ERROR unity expected. insert a semicolon at the end 2 Answers
Script error help ? 1 Answer