Error: Undefined is not a function

I got an error message that said, ‘‘TypeError: undefined is not a function’’
How do I fix it?

*title test
*scene_list
test
*author Fives and TheGlobeh/Cosmo
*comment Its the year 3056, and it’s July 9th.
Three empires have risen about 100 years ago, when the warring began.
The Volar Empire. The Bastyan Empire. And the Qazar Empire.
These three empires have different ideas, and they fight over mostly control, and getting their idea delivered.
The Volar Empire wants order, balance, and laws.
The Bastyan Empire wants peace, and freedom.
The Qazar Empire wants destruction, control, slaving, and power.
*comment Races
*comment Human, A strong minded race, that is equal in all, strength, smarts, and speed.
Since thousands of years have passed since the human world of Earth was rich with resources, the humans have started shrinking in numbers. And now only about a billion or so humans remain.
*comment Ragnor, A large greenish brute type creature, with sharp teeth, and stands at about 8-10 feet tall.
Their physical strength is incredible, but mentally, they aren’t that smart. It’s rare for a Ragnor to be as smart as a human but, it sometimes happens. The Ragnor used to be only found on the planet of Cazar, but now that there is more of them, they are in other planets. No one knows where these creatures came from, but, they were used as slaves or body guards at one point, and now they mostly serve the Qazar Empire, as big brutes, that are like tanks. They also have sharps claws, and other features, that are alien like.
There is only about half a billion of these Ragnor that are known to be alive.
*comment Zaen, A very smart creature, some say some of these creatures can be up to 7x as smart as a human. They are pretty weak physically though. And their speed is slightly faster than a human. They are one of the oldest races, proved, and they usually supply the military forces. There is about a billion of these creatures out there, known.
*create male false
*create female false

*choice
#Join an empire
You need to grow stronger to someday take matters into your own hands.
*choice
#Join the Valor Empire
*finish
#Join the Qazar Empire
*finish
#Join the Bastyan Empire
*finish
*choice
#What is your gender?
I must know.
*choice
#Male
*finish
*choice
#Female
*finish

I would guess it is your unnecessary choice command at the bottom. Undefined is not a function is the system complaining you have tried to set a value as nothing. when you put in the *choice command it is informing the system that you are about to add a choice. Adding nothing underneath it suggests the choice is nothing.

Also just fyi, you only need to add the choice command once above each set of choices. While the text remains indented the system will assume everything underneath it is a potential choice.

‘’ #Join the Bastyan Empire
*finish
*choice ‘’

That was supposed to be for the next line of code, ‘‘What is your gender?’’ the *choice before that was supposed to be for ‘‘What is your gender?’’ unless your not talking about that all all.

Is the spacing you’ve posted in your original post the same spacing you’re using in the game? Your indentations look off.

Also to get the coding to show properly on the forums highlight the code and then hit the preformatted text button (it’s in the bar next to the quote one, or ctrl+k).

If you delete all the text below your first *choice does the scene run?

@FairyGodfeather If I delete all the first *choice paragraph then it still does not work.

I deleted that vvvv

 *choice
#Join an empire
You need to grow stronger to someday take matters into your own hands.
*choice
#Join the Valor Empire
*finish
#Join the Qazar Empire
*finish
#Join the Bastyan Empire
*finish 
*choice

You can’t have plain text before your *create commands, though this should throw a different error, not the one you’re experiencing. Are you running the game in the latest copy of Choicescript from Github?

The spacing as you’re reproducing it here still looks off, but either way is the only option for your first *choice to #Join an empire? Putting a *finish after each of those options effectively means they don’t do anything.

Why not try rewriting it as simply:

*create empire "none"
You need to grow stronger to someday take matters into your own hands.  That means joining an empire:
*choice
  #Join the Valor Empire
    *set empire "Valor"
    *finish
  #Join the Qazar Empire
    *set empire "Qazar"
    *finish
  #Join the Bastyan Empire
    *set empire "Bastyan"
    *finish

@distracteddad Thank you for the help but the error still keeps happening, after I tried your advice.
@CJW I downloaded the Choicescript from this link: https://www.choiceofgames.com/make-your-own-games/choicescript-intro/

Then the error is bein caused by something around that area rather than that choice itself. All I can say is to make sure every choice has options, that every option ends with either a *goto or *finish, and that everything is properly indented.

Okay I’m gonna look through everything again. This is my updated script now:

*title test
*scene_list 
 test
*author Fives and TheGlobeh 
*comment Its the year 3056, and it's July 9th.
Three empires have risen about 100 years ago, when the warring began.
The Volar Empire. The Bastyan Empire. And the Qazar Empire.
These three empires have different ideas, and they fight over mostly control, and getting their idea delivered.
The Volar Empire wants order, balance, and laws.
The Bastyan Empire wants peace, and freedom.
The Qazar Empire wants destruction, control, slaving, and power.
*comment Races
*comment Human are a strong minded race, that is equal in all, strength, smarts, and speed.
Since thousands of years have passed since the human world of Earth was rich with resources, the humans have started shrinking in numbers. And now only about a billion or so humans remain. 
*comment Ragnor are large greenish brute type creatures, with sharp teeth, and stand at about 8-10 feet tall.
Their physical strength is incredible, but mentally, they aren't that smart. It's rare for a Ragnor to be as smart as a human but, it sometimes happens. The Ragnor used to be only found on the planet of Cazar, but now that there is more of them, they are in other planets. No one knows where these creatures came from, but, they were used as slaves or body guards at one point, and now they mostly serve the Qazar Empire, as big brutes, that are like tanks. They also have sharps claws, and other features, that are alien like. 
There is only about half a billion of these Ragnor that are known to be alive.
*comment Zaen are very smart creatures, some say some of these creatures can be up to 7x as smart as a human. They are pretty weak physically though. And their speed is slightly faster than a human. They are one of the oldest races, proved, and they usually supply the military forces. There is about a billion of these creatures out there, known. 
*scene_list 
test 

*create empire "none"
You need to grow stronger to someday take matters into your own hands.  That means you need to join an empire. 
*choice
  #Join the Valor Empire
    *set empire "Valor"
    *finish
  #Join the Qazar Empire
    *set empire "Qazar"
    *finish
  #Join the Bastyan Empire
    *set empire "Bastyan"
    *finish

*create gender "none"
*choice      
  #Male
   *set gender "Male"
   *finish
   *choice
  #Female
   *set gender "Female"
   *finish

I noticed two things. You have the *scene_list command in there twice; below the *title and after all the *comments. Try deleting one of those and see if that helps. You also can’t add new *create commands in the middle, they all have to be together near the top. So all you need to do is just move the *create gender to below or above the *create empire.

Also, an extra tip: the *finish command takes you to the next scene in the list, if you want the reader to go from choosing which empire they join to choosing their gender you’d need to do something like this:

*choice
  #Join the Valor Empire
    *set empire "Valor"
    *goto gender
  #Join the Qazar Empire
    *set empire "Qazar"
    *goto gender
  #Join the Bastyan Empire
    *set empire "Bastyan"
    *goto gender
*label gender
*choice
  #Male
    *set gender "Male"
    *finish
  #Female
    *set gender "Female"
    *finish

@Pangolin Thanks for the advice but it still doesn’t work after I did everything you said.

Hmm…the only other thing I could think of is making sure the scene you have under *scene_list is the same name you have for the file you’re editing.

When you first downloaded choicescript were you able to open the example game they had?

Yes I could. And I tried copying and pasting my script bit by bit, into choicescript, and when I put in the scene_list it made an error. So I deleted the scene_list, and tried running the script, but it still won’t run after another error. This other error says exactly this,

JavaScript Alert
Uncaught SecurityError: Blocked a frame with origin ''null'' from accessing a cross-origin frame

Have you only been editing the text documents in the scenes folder?
Do you still have a text doc named startup and another named choicescript_stats?

I played around in choicescript for a bit and the bare minimum needed to open without errors is, within the scenes folder, to have a text doc named startup (it can be completely blank as long as the file is named startup, but it is the file you’ll need to put your *title, *author, *scene_list, and *create commands in) and in order for the stats screen not to show an error you have to have another text doc named choicescript_stats and have at least one *stat_chart command typed in there.

Maybe as a last resort you can redownload choicescript?

@Pangolin Alright. I’ll try everything, and I’ll tell you if I still need help after that. Thanks again.