Garry's Mod Wiki

Revision Difference

NPC:SetExpression#510484

<function name="SetExpression" parent="NPC" type="classfunc">⤶ <description>Sets the NPC's .vcd expression. Similar to <page>Entity:PlayScene</page> except the scene is looped until it's interrupted by default NPC behavior or <page>NPC:ClearExpression</page>.</description>⤶ <realm>Server</realm>⤶ <args>⤶ <arg name="expression" type="string">The expression filepath.</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="number"></ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Function which makes the NPC whom the player is looking at repeat an annoying scene.</description>⤶ <code>⤶ function GrenadesScene(ply)⤶ ⤶ if(!IsValid(ply)) then return end⤶ ⤶ local npc = ply:GetEyeTrace().Entity⤶ ⤶ if(IsValid(npc) &amp;&amp; npc:IsNPC()) then⤶ npc:SetExpression("scenes/streetwar/sniper/ba_nag_grenade0"..math.random(1, 5)..".vcd")⤶ end⤶ ⤶ end⤶ </code>⤶ ⤶ </example>