Hi, at the moment I’m trying to create a function so when you call SetModel on a player it calls SetModel on an entity with the same arguments, while ignoring the SetModel called on the player. I asked around somewhat, and got some code from a friend. It is as follows:
d=ents.Create("dummy") d:SetPos(Vector(0,0,100)) d:Spawn() d:Activate() plr=player.GetHumans() Obj=d getmetatable(Obj).SetModel = (function (Str) plr:SetModel(Str) end) Obj:SetModel("models/headcrab.mdl")
(the Dummy entity is just a regular entity with no special code attached, sort of like prop_physics)
Now what I think this should do is when I call Obj:SetModel on the last line, it should set the player’s model to a headcrab. However all I get is the following error
[lua\autorun\server\fakemodel.lua:9] stack overflow
Any reasons or fixes for this? I’d much appreciate the help.