Need help with Entity Scale Modeling please :/

When I spawn this entity I want the model bellow to be scaled by 2x its size


DEFINE_BASECLASS( "gf2_base_adv" )

ENT.Spawnable		= true
ENT.AdminOnly		= false

ENT.PrintName		             =  "8Inch Mortar Tube"
ENT.Author			     =  "Rogue Cheney"
ENT.Contact		             =  ""
ENT.Category                         =  "G-Works 2 - Mortars + Shells"

ENT.Model                            =  "models/models/gf2/rogue_cheney/mortars/mortar_03.mdl"

ENT.Mass                             =  150

ENT.GBOWNER                          =  nil

ent:SetModelScale( ent:GetModelScale() * 1.25, 1 )

This line of code doesn’t work. “ent” is a nil value. Please help!!

firstly, ent isn’t ENT; the upper/lowercase status matters for it to be the same variable


gmod reads entity files by creating a global empty table called ENT, and then reading the entity file, applying anything inside it to the ENT table, which is just a set of data and words (not an entity), and then saves this data under the entity’s name so that when the entity is actually created it can be created based on that stored data

you’re trying to set the model scale when the code is just trying to learn, ahead of time immediately when the game starts, what variables and functions all instances of future mortar tubes will possess

so in this area, ENT means ‘the template for entities created based on this template in the future’

what you’re looking for is:

function ENT:Initialize()

inside a function defined as “function table:functionName()”, the term self will always refer to the entity that exists in the future, instead of the ENT template; Initialize is a function name that the game will call after it creates the entity based on the ENT template