Ask coding questions

← Back to all posts
I can't get whatever functions I store within the script.js file to work in the html. Plz help.
ChipSlayer

If I create a new script tag to call the functions in, I think there's an error with scope. Otherwise I just don't get an output. If I don't use my custom functions but paste the code from the custom functions straight into the script tag it works fine. I really need help. My eventual plan is to create a library filled with visual commands and other useful functions, but I can't get custom-libraries to import correctly or something...

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
ChipSlayer
Comments
hotnewtop
Coder100

Because you added a script.js, any code inside the script won't run. You will have to either: split into a new script tag, or create a new file.

  1. new script tag
  1. new file
    create a new client.js
    and inside, put whatever code you need, like:

then in your HTML:

ChipSlayer

@Coder100 Thanks! This was very insightful and helpful. I found out I was calling the wrong function, which was making nothing work, but this is kind of useful knowledge that will help me in the future.

Coder100

@ChipSlayer glad to help!

ch1ck3n

this shoud be your html

ChipSlayer

@ch1ck3n Thanks!! Funny thing is I had tried this, and it still wasn't working until I realized that I called beginShape instead of beginPath. Now it works just like you said.