Hello,
I have this script that animates the NPC depending on its humanoid.Running (speed) I’m having trouble figuring out on how do I properly detect movements.
humanoid.Running:Connect(function(speed)
if speed >= monster:GetAttribute("RunSpeed") - 1 then
if runAnim.IsPlaying == false then
runAnim:Play(0.2, 3, 1)
end
elseif speed >= monster:GetAttribute("WalkSpeed") - 1 and speed < monster:GetAttribute("RunSpeed") - 1 then
if walkAnim.IsPlaying == false then
walkAnim:Play(0.2, 2, 2.4)
end
elseif speed >= 0.1 then
if crawlAnim.IsPlaying == false then
crawlAnim:Play(0.5, 1, 2.3)
end
elseif speed == 0 then
idleAnim:Play(0.5, 1)
crawlAnim:Stop(1)
walkAnim:Stop(0.5)
runAnim:Stop(0.5)
end
end)
The issue is when testing it on studio it works perfectly fine transitioning to run, walk, crawl, idle animations. detecting proper speeds without humanoid.Running firing too often returning exact speeds. eg. RunSpeed, WalkSpeed of the humanoid.
And Testing it now on the live server
The humanoid.Running fires inconsistently or too many. When I set the humanoid walkspeed it’s speed from WalkSpeed = 8 to WalkSpeed = 20 it also fires and returns the in-betweens and also returns 0 Speed when even tho it’s moving…??
Assuming it’s moving on a straight line. setting its speed from 8 to 20 and printing its return argument.
eg.
speed 8 => 20
It prints 0, 8, 0, 9, 0, 10, 0, 11 ,12, 13 and so on…
On Studio:
it prints 8, 8.1, 20 which is fine. (Not returning 0 speed while moving)
hence when it returns 0… per frame it stops the runAnim and play’s the idle and the next frame it plays the runAnim again, giving its jittery motion per frame. It’s so hard to solve this issue because it’s not consistent from studio to live server.
Do note:
I tested it from using this
And also this
And works perfectly fine.