Set entity model after entity is spawned?

Hey there!

I’ve been having some issues with a simple bit of code I’ve been trying out. I want to set the model of a TTT corpse entity when it’s identified if the body belonged to a Traitor. However, I can’t seem to set the model without making it invisible for anyone who was within render range of the entity. The only way to get the entity to render again is to leave its render area and come back.

My issue with most things is that I am only allowed to use serverside functions because of the way the TTTBodyFound hook works. I could do some networking, but I’d prefer to stay away from it unless it’s the only way to go, mostly because I’m not sure how I would go about this using networking.

If anyone knows what might be the issue and/or the solution, please, let me know.

The code I’m trying to use (in lua/autorun):

local changeling = Model("models/player/mlp/changeling_player_colorable_v2.mdl")

if SERVER then
	hook.Add("TTTBodyFound", "pp3-set-changeling-model", function(finder, deadply, corpse)
		if corpse.was_role == ROLE_TRAITOR then

Again, if you know anything of use, please help out! Thank you!

ninja edit: Removed silly hacky attempt at getting things to work — same problem with or without it.


local changeling = "models/player/mlp/changeling_player_colorable_v2.mdl"

I’ll try that when I get the chance, but what would that do besides not precache the model?

You can’t just set the Model of a corpse.
You still have to redo physics of the ragdoll etc.

The models we’re using should be on the same skeleton, etc, and they render and work fine. The only issue is, again, them not appearing until re-rendered.