Triggering a prop_physics animation via lua

I have a prop_physics model I created that has an animation I would like to trigger one time whenever the player presses use (E) on it. Prop_physics models are able to send an output on player use, but they cannot be dynamically animated through map logic like a prop_dynamic.

So I am wondering if it is possible to have the prop_physics trigger a lua_run that has code to animate the named model? If so, how is this possible? I’m not an avid lua coder myself so any help is greatly appreciated.

In a

GM:PlayerUse hook, call

Entity:SetSequence on the used entity, might work.

[editline]17th October 2017[/editline]

If the PlayerUse hook isn’t triggered, you can try making a trace in this hook:

GM:KeyRelease

It doesn’t have to deal with player use at all, since the physics prop can trigger a lua_run through map logic when a player presses E on it. I just need to figure out code that will play an animation sequence once on a named prop_physics model then return to idle when that sequence is finished.

Not sure I fully understand, but try this:
[lua]
local prop = ents.FindByName(“your prop targetname here”)[1]
prop:SetSequence(“your sequence name here”)
[/lua]

Hmm, that doesn’t seem to work.

You cannot animate prop_physics.

Ok, thanks. I have it working by faking it using my model as a non-solid prop_dynamic parented to an invisible func_physbox for a collision that sends output to the prop_dynamic to animate it when a player presses use on the func_physbox. It just seems a little “hacky” but I suppose it will have to do.