Garry's Mod Wiki

Lua Folder Structure

Lua Folder Structure

The main game directory for Garry's Mod is the garrysmod folder located next to the game's executable hl2.exe, and contains much of the content you see while playing the game. This includes Lua scripts, sound effects, 3D models, and more. Each Addon for Garry's Mod needs its own folder in garrysmod/addons/ that will hold all of its content.

Addons and Gamemodes have a nearly identical folder structure to the garrysmod folder. When making an Addon, all folders are optional and only those that your Addon requires should be created in order to keep your Addon's folder structure clean and easy to navigate.

Because this folder structure is applicable in multiple situations, the generic term {Root} is used here to mean the folder at the base of the game, Addon, or Gamemode. Folders that are meant primarily for use by Garry's Mod internally are marked with [I] to mean "Internal" and should not be modified unless you have a good reason to be doing so. Keep in mind that adding or modifying files outside of an Addon or Gamemode is discouraged because it can lead to file conflicts and unexpected behaviors. With very few exceptions, any change or addition made to Garry's Mod should be done using an Addon or a Gamemode.

Please note: This is not an exhaustive list. This list is primarily intended to give a general overview of the game's folder structure as it relates to lua scripts, with more detailed information where it is relevant for Gamemode and Addon creation.

├── lua
│ ├── autorun - Scripts in this folder are run automatically when Lua starts on both Client and Server (Called "Shared") realms.
│ │ ├── client - Runs its contents automatically in the Client realm.
│ │ ├── server - Runs its contents automatically in the Server realm.
│ │ └── properties - Holds the default Properties used in The Context Menu, which are loaded by lua/autorun/properties.lua
│ ├── bin - Where Binary Modules, an advanced feature, should be placed.
│ ├── derma - Where Derma utility scripts should go.
│ ├── drive - A dedicated folder for scripts relating to the Drive system.
│ ├── effects - Where scripts for custom Lua-based Effects go.
│ ├── entities - Scripts placed here will be loaded as Scripted Entities (SENTs).
│ ├── includes - [I] This is where init.lua (The first lua file executed when lua starts) is located.
│ ├── matproxy - For scripts relating the Material Proxy (matprox) library, used to create per-entity materials.
│ ├── menu - [I] Similar to the includes directory but for the game's main menu. Starts by running menu.lua.
│ ├── postprocess - Where scripts defining Post-Processing Materials are located.
│ ├── skins - Where scripts defining Skins for the Derma library are placed.
│ ├── vgui - Scripts defining Derma interface elements like DButtons and DSliders.
│ └── weapons - Scripts placed here will be loaded as Scripted Weapons (SWEPs)
│ └── gmod_tool - This folder is created by the Toolgun in the Sandbox Gamemode.
│ └── stools - This is where lua files for Scripted Tools (STOOLs) used with the Toolgun are placed.
└── gamemodes - Gamemodes can be thought of as Addons that are only active while they are being played.
└── {Gamemode Name} - Each Gamemode gets its own folder, which acts as its {Root} directory.
└── gamemode - This folder must exist and must contain at least init.lua and cl_init.lua for the Gamemode to work.