Hello, im trying to make it so when my Enemy NPC is going towards to player a different, faster walking sound will play, and when he is walking around randomly, a different, slower walking sound will play. However in the following code my issue is that it doesnt work after the player gets out of range/gets killed, but the running sound is mixed with the walking sound and its weird. Here is the code:
function main() local target = findTarget() if target then myHuman.WalkSpeed = 16 if script.Parent.Head.Walking.IsPlaying then script.Parent.Head.Running:Play() else script.Parent.Head.Running:Play() end findPath(target) else myHuman.WalkSpeed = 7 if script.Parent.Head.Running.IsPlaying then script.Parent.Head.Walking:Play() else script.Parent.Head.Walking:Play() end walkRandomly() end end
If needed, i can edit this post for the full script.
To clarify, im trying to make it so when an NPC is running towards a player the running sound is played, and when the NPC is wandering around, the walking sound is being played.