What do I do when This error shows up ?
Please Help ! What Do I Do when this ERROR shows up :
Assets/KillOnHit.js(8,9): BCE0044: expecting), found 'var'.
From the Series of MAKE A GAME (By Brackeys) Video 22
The script :
You've got an extra ( before "Player", and no { after the if statement on the same line. You'll also need an extra } at the bottom of the script.
Unrelated to the original issue var Destructible
should be written with a lower case d. You are declaring a variable there and calling Destruct() on it on the next line so use the same case for both.
I changed the mistake but the same error still shows up
is the script still correct :
Answer by Dibbie · Jun 13, 2016 at 12:24 PM
Youd want to update your code to the following:
if (colInfo.tag == ("Player")){
var destructible = colInfo.GetComponent ("Destructible") as Destructible;
destructible.destruct();
}
Your main issue is, after ("Player"), you dont have a closing brace ) for your if-statement - as well I noticed you also dont have a starting curly brace { for your if-statement either. Now taking a second look, you also technically dont have an ending curly brace } for that if-statement either, so your code will run and the error will go away once you add that closing brace ) - but you probably wont get the results you expected - when you dont specify curly braces with if-statements, it will only read the following line under it, as the "if statement", so only line 8 is considered a part of the if-statement to line 7, and like 9 is considered part of line 6's if-statement.
Thanks, but then these two errors show up:
1.Assets/$$anonymous$$illOnHit.js (6,24) 'is Restarting' is not a member of 'Game $$anonymous$$aster'
2.Assets/$$anonymous$$illOnHit.js (13,19) 'RestartLevel' is not a member of 'Game $$anonymous$$aster'
The script:
Dibbie answered the question. Should accept answer.
The new errors are unrelated to the question. Restarting and RestartLevel don't exist in Game$$anonymous$$aster, add them.
Your answer
Follow this Question
Related Questions
Cant Change lighting/scene variables,Cant Change Lighting Properties 0 Answers
Prefabs holding variables,How to carry accross game objects to prefabs 1 Answer
Use of unassigned local variable 'startPos' " & " Use of unassigned local variable 'endPos' 1 Answer
Variable Never Used Stopping Game From Running 3 Answers
How can I access an int variable from another script? 1 Answer