manhack npc control

So I need to control a manhack npc based on the left mouse button. The mouse button part works it’s just that most of my methods of getting the npc manhack to move have crashed the server.

These attempts have included applyforce and Ent:SetVector ( same as the code below except a change to mhent:SetVelocity )



function KeyPressed (ply, KEY_LEFT )
	local traceRes = ply:GetEyeTrace()	
	while ply:KeyReleased( KEY_LEFT ) != true do
		Msg ("KAOOM AND THE STAIN IS GONE
") --dev message
		local mhent = ents.FindByName( "plymanhack-" .. ply:Nick() )[1] --the manhacks name
		mhent:GetPhysicsObject():ApplyForceCenter( traceRes.HitPos )
	end
end


All I want to know is how to get a manhack to budge towards any Pos while left mouse is pressed

-snip- sorry I misunderstood.

Try setting last position, then setting a running schedule on it, it will not strafe, but it will go to the direction you specified in the Set Last Pos function.

**[NPC.SetLastPosition

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=NPC.SetLastPosition)**
**[NPC.SetSchedule

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=NPC.SetSchedule)**