This.hits(): clip not defined

i always get this bug wick isn’t reading my code heres a screen shot

you saw that “that” is not defined andi dont know how to fix this or wick’s devs to fix it
can you tell me a code so i will fix it? or you can heres the Project (3.0 MB)

You need to replace that with an object/clip eg. project.box

1 Like

You have to define that… as the Console is telling you… replace that by the clip that you are interested…

oh i know whats happening its because probably the object is removed so maybe that is the problem

so it looks like your object is literally called “that”. i guess that works, but you can see in the first picture how the name turns blue. i think that means it’s a built-in javascript thingy, so it’s better to use a different name, one that isn’t already taken.

the actual problem you are getting is that one frame after the clip is removed, “that” no longer exists and it isn’t defined, causing the error.

maybe thats the problem but i made it teleport to another object now it works but we have another problem Screenshot 2022-05-14 5.28.42 PM

O_o

Just name the clip a different thing and replace the word “that” with the new name of the clip.

Also i would recommend using semicolons at the end of those lines, as the editor also recommends if you hover your mouse of the “i”

yea i use semicolons sometimes

Please make more descriptive topic titles. Also were there more than one object named “that”? As Donut said, you should name your clips more specific things than “that”.

About the semicolons

Putting semicolons is good practice in JS since JS uses semicolons to declare the ends of statements. If you don’t include a semicolon, JS will guess where the semicolon would be and automatically places it there. But you may be in a situation where JS puts the semicolon in a wrong place because JS guessed wrong, for example when you use an immediately invoked function expression

(function() {
  …
})();

If you don’t put a semicolon on the statement before you declare an IIFE, JS will mistake it for a function call on the previous statement and your code will not work as intended.

Also the text editor has a max amount of info/error/warning bubbles it can use. If you don’t put semicolons, the available slots will fill up fast and eventually you won’t be able to see syntax errors later in the code.

i dont even know why i said this is an bug

why do i have this too???

i missed the semicolon btw

is a1 the name of a clip on the same frame as that clip?

1 Like

no, besides i cant find tthe code thats messing it up and causing the error
heres the project its called koko sandwich (424.5 KB)