Module Script not loading

I was just testing out a part of my game when this error appeared and stopped an important script from working, this was the error:
“Requested module experienced an error while loading”
The module script that was not loading only has 38 lines of code and is only tables, does anyone know why this is happening?

Thanks! :smile:

2 Likes

Could you show us the code of the module? This error often occurs because of a syntax error in the module.

3 Likes

Make sure the module returns one value at the end. It would help if you sent it here.

1 Like

Here is the module:

local GameModes = {}


GameModes.AllGameModes = {
	["Running"] = {
		["Speed"] = "Player Choice"; --Whatever the player has as speed (their upgrades)
		["Jump"] = "Player Choice";
		["Vehicles"] = false;
		["Camera"] = "Custom"
		
	};
	["Speed Run"] = {
		["Speed"] = 100;
		["Jump"] = "Player Choice";
		["Vehicles"] = false;
		["Camera"] = "Custom"
	};
	["Vehicle Race"] = {
		["Speed"] = 0;
		["Jump"] = 0;
		["Vehicles"] = false;
		["Camera"] = Enum.CameraType.Scriptable
	};
	["Bot Race"] = {
		["Speed"] = "Players Choice";
		["Jump"] = "Players Choice";
		["Vehicles"] = false;
		["Camera"] = "Custom";
		["Bot Speed"] = "Player Speed"
	}
}






GameModes.PublicGameModes = {
	["Lobby Stage"] = {
		[1] = game.Workspace.LobbyStage.LobbyPhysicalStage.PlayerStageSpawn.Position;       --Stage Number must go first! Then stage player teleport location
		["Running"] = "Stage Type"
		
	};	
	
}

GameModes.PrivateGameModes = {
	"Place Holder"
}

return GameModes

game.Workspace.LobbyStage.LobbyPhysicalStage.PlayerStageSpawn.Position

Make sure this exists in your workspace, it could be the cause of the error

1 Like

Change the function listing or whatever from GameModes.AllGameModes to function GameModes.AllGameModes for example.

Edit: This is not necessary, only do this if you want this to be a callable function. In this scenario, it’s being used as an enum, so there isn’t a need for the function part.

1 Like

That exists in the game and is not the issue I think.

Why would you need to do this?

Because that is how modules work…

Could you give us a screenshot of your output when the error occurs?

That is not how modules work, you don’t need functions to get data from modules. You can store them directly into the module itself.

3 Likes

Ok it worked, I just forgot I changed the models name. :grinning:

2 Likes

Right, I’m sorry, I didn’t look at the whole thing. I guess thats more like a custom Enum thing

Ok the module script randomly starting erroring again, it was fine yesterday but today it broke again. Do you know why?

Did you save the file before closing it?

I used the wrong variable and it took me a while to figure it out lol, thanks for your help though!
:smile:

1 Like