Uncaught ReferenceError

I am, getting this error "Error: Uncaught ReferenceError: Menu is not defined Script: nui://vrp/gui/main.js Line: 19 Column: 22 StackTrace: ReferenceError: Menu is not defined.

The code is down below, I can’t seem to find any error.


Just for future reference, it is much better if you send us a link to your code repo so we can look at everything and test it for ourselves.

Regarding your question, the error is telling you that the Menu object you are trying to create is not defined anywhere. In other words, JS doesn’t know how to make a Menu object because you haven’t given it the definition (either in a class or object definition).

This is where it would help to be able to see your entire project. Have you defined Menu somewhere else? Are you including it as a JS library? What have you done to allow you to create that Menu object in the first place?


This is what, the code looks like. I havn’t defined the menu any other places then in the file “design.css” and menu.js

Sorry, I’m not familiar with pastebin so I may be missing something here.

From what I can tell you have defined an event listener for when the page has loaded and then once that happens you are trying to create a ‘dynamic menu’ by instantiating a Menu object:

var dynamic_menu = new Menu();

Why do you think you can use new Menu() to do this? You mentioned menu.js but I don’t see that in the link you gave us. If Menu is defined in menu.js how you are including menu.js in your project?

Im kinda, new to coding. So I tried to look at the standard files that was included in vRP, and tried to create a menu out of that.

Here is the menu.js file, whenever I put that in. It creates an error in the console, and the menu won’t load in. And by putting it in I mean into, a folder called “Gui” that is supposed to load those files in within the folder.

Well, I don’t know what vRP is or what adding the file to a folder called “Gui” does but the menu.js you shared with me defines a function named MENU and you are trying to call it as new Menu(); So you at least need to change that to new MENU();.