I’m trying to make a footstep system for an NPC which walks around, and I’ve run into a problem. When trying to use Humanoid.MoveDirection.Magnitude on a server-side script, the magnitude is always 0 regardless of if the humanoid is moving or not. If you’re wondering I am moving the NPC by using Humanoid:MoveTo(). If you’re wondering I have tried to use Humanoid.Running:Connect but it is unreliable since it only plays the footsteps when it finishes walking to a waypoint. If you have any solutions or a way to play footstep sounds on an NPC please reply thanks!
ServerScript:
local CD = true
function playstep()
local humanoid = script.Parent.Humanoid
local direction = humanoid.MoveDirection.Magnitude
local rootPart = script.Parent:WaitForChild("HumanoidRootPart")
if CD and humanoid.MoveDirection.Magnitude > 0 then
CD = false
local sound = script.Parent.HumanoidRootPart.Footsteps
local pitch = sound.EqualizerSoundEffect
local hg = math.random(0,10)
local lg = math.random(0,10)
local mg = math.random(0,10)
pitch.HighGain = hg
pitch.LowGain = lg
pitch.MidGain = mg
sound:Play()
sound.Ended:Wait()
CD = true
end
playstep()
end
spawn(playstep)