What event signal/listener would work for a moving NPC (both in position and orientation)

I’m wondering about any sort of signalling for when an NPC/character is moving or looking in a different direction in terms of PrimaryPart, I wanted to find a method that would be plug and play and not have me go into parts of code and insert some sort of bindableevent trigger though that may end up being the case

the bottom sample code actually never triggers which I find strange since previous code has worked but admittedly I’ve only used them on regular object and not NPC humanoids so that may be this issue


	self.Events.PrimaryPartMoved = self.PrimaryPart.Changed:Connect(function(Property)
		
		if Property == "Position" or Property == "Orientation" then
			
			
		end
			
		
		
	end)


-- other code

local Connection

Connection = PrimaryPart:GetPropertyChangedSignal("Position"):Connect(function()

end)
1 Like

This is what ended up being my solution as I dug deeper–can’t do changed signal for physics object apparently.


local OldPosition = Vector3.zero
	local OldOrientation = Vector3.zero
	self.Events.PrimaryPartMoved = RunService.Stepped:Connect(function()
		
		if (OldPosition ~= self.PrimaryPart.Position and (self.PrimaryPart.Position-OldPosition).Magnitude>.01) 
			or (OldOrientation ~= self.PrimaryPart.Orientation and (self.PrimaryPart.Orientation-OldOrientation).Magnitude>.18) then
			
			
			--change occured proc assessments
			
			OldPosition = self.PrimaryPart.Position
			OldOrientation = self.PrimaryPart.Orientation
			
			
			
			
		else
			
			return
			
		end
		
		
		
	end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.