Skip to content
Creating Your Own Simple Addons (Basic Introduction)
Garry's Mod

Creating Your Own Simple Addons (Basic Introduction)

Create your first Garry's Mod addon. Learn basic addon structure, folder organization, and how to add custom props using Lua scripts.

By ···10 min read·Multi-source verified
1 reading this guide  

Create your first Garry's Mod addon. Learn basic addon structure, folder organization, and how to add custom props using Lua scripts.

4.9. Creating Your Own Simple Addons (Basic Introduction)

Garry's Mod's extensibility is one of its greatest strengths, and creating your own simple addons is a fantastic way to personalize your gameplay or share your ideas with the community. This introduction will guide you through the fundamental concepts and steps involved in making your first basic addon.

Addons in Garry's Mod are essentially custom content that extends the game's functionality. This can range from new weapons and entities to entirely new game modes. For beginners, starting with simple addons like custom props, simple tools, or basic Lua scripts is the best approach. This section will demystify the process and provide a clear path to creating your first functional addon.

Understanding Addon Structure:

Garry's Mod addons are typically organized within a specific folder structure, usually located in your `garrysmod/addons` directory. Each addon has its own folder, containing subfolders for different types of content.

  • `lua/`: Contains all Lua scripts that define your addon's logic and behavior.
  • `models/`: For custom 3D models.
  • `materials/`: For custom textures.
  • `sound/`: For custom sound files.
  • `gamemodes/`: If your addon is a new gamemode.
  • `entities/`: For custom entities.

Creating a Simple Prop Addon:

Let's create a basic addon that adds a custom prop. This requires a model file (`.mdl`) and its associated texture files (`.vmt` and `.vtf`).

  1. Create Addon Folder: In your `garrysmod/addons` directory, create a new folder for your addon, e.g., `my_custom_prop`.
  2. Create `materials` and `models` Folders: Inside `my_custom_prop`, create `materials` and `models` folders.
  3. Place Model and Textures: Place your `.mdl` file in the `models` folder and its corresponding `.vmt` and `.vtf` files in the `materials` folder.
  4. Create `autorun` Folder: Inside `my_custom_prop`, create a `lua` folder, and inside that, create an `autorun` folder.
  5. Create Lua Script: Inside the `autorun` folder, create a file named `my_prop_loader.lua`.
  6. Add Lua Code: Open `my_prop_loader.lua` and add the following code (replace `models/your_model_path.mdl` with the actual path to your model):

if SERVER then
 AddCSLuaFile("my_prop_loader.lua")
end

-- Register the prop as a spawnable entity
ENT.Type = "prop"
ENT.Base = "base_gmodentity"
ENT.PrintName = "My Custom Prop"
ENT.Category = "My Props"

function ENT:Initialize()
 self:SetModel("models/your_model_path.mdl")
 self:SetSolid(SOLID_VPHYSICS)
 self:PhysicsInit(SOLID_VPHYSICS)
end

-- Register the entity for the spawn menu
if CLIENT then
 
 local PANEL = vgui.Register("MyCustomPropSpawn", { 
 OnCreate = function(self) 
 self:SetSize(200, 50)
 self:SetText("My Custom Prop")
 self:SetModel("models/your_model_path.mdl")
 self:SetTooltip("Spawn My Custom Prop")
 end
 })

 PANEL:AddClass("MyCustomProp")

end

This script registers your model as a spawnable entity. When Garry's Mod loads, the `autorun` script will execute, making your prop available in the spawn menu under the "My Props" category.

This is a very basic example. As you become more comfortable, you can explore adding custom behaviors, tools, and more complex entities using Lua.

100% Human-Written. AI Fact-Checked. Community Verified. Learn how AntMag verifies content