How do I change an entities model with a normal function?
2 replies, posted
Hey!
I have this Entity I made of which I want to change the model of in a custom function. How would I go about doing that? I have tried this:
[lua]
function change()
ENT:SetModel("blah.mdl")
end
[/lua]
But it just throws an error about ENT being nil. Help!
[LUA]function ENT:Change()
self:SetModel( "blah.mdl" );
end[/LUA]
Then, to call
[LUA]
function ENT:Use()
self:Change();
end
[/LUA]
[QUOTE=Chizbang;42691752]Hey!
I have this Entity I made of which I want to change the model of in a custom function. How would I go about doing that? I have tried this:
[lua]
function change()
ENT:SetModel("blah.mdl")
end
[/lua]
But it just throws an error about ENT being nil. Help![/QUOTE]
That's because ENT is undefined. You can use an argument to represent the entity in your function like this:
[lua]
function change(ent)
ent:SetModel("blah.mdl")
end
[/lua]
Then call it by using change(entity)
Sorry, you need to Log In to post a reply to this thread.