Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I fix the this jump anim scipt?

local character = script.Parent
02	local humanoid = character:WaitForChild("Humanoid")
03	 
04	local walkAnim = script:WaitForChild("Walk")
05	local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)
06	 
07	local idleAnim = script:WaitForChild("Idle")
08	local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)
09	 
10	local jumpAnim = script:WaitForChild("Jump")
11	local jumpAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)
12	humanoid.Running:Connect(function(speed)
13	    if speed > 0 then
14	        if not walkAnimTrack.IsPlaying then
15	            walkAnimTrack:Play()
16	        end
17	    else
18	        if walkAnimTrack.IsPlaying then
19	            walkAnimTrack:Stop()
20	        end
21	    end
22	end)
23	 
24	humanoid.Running:Connect(function(speed)
25	    if speed > 0 then
26	        if idleAnimTrack.IsPlaying then
27	            idleAnimTrack:Stop()
28	        end
29	    else
30	        if not idleAnimTrack.IsPlaying then
31	            idleAnimTrack:Play()
32	        end
33	    end
34	end)
35	 
36	humanoid.Running:Connect(function(speed)
37	    if speed > 0 then
38	        if not jumpAnimTrack.IsPlaying then
39	            jumpAnimTrack:Play()
40	        end
41	    else
42	        if jumpAnimTrack.IsPlaying then
43	            jumpAnimTrack:Stop()
44	        end
45	    end
46	end)

2 comments

0

You jump isnt working because it doesnt depend on speed!

0

In line 11 you used idle animation for jump....

1 answer

Your jump animation is not working because jumping does not depend on speed. There are 2 ways to detect if a player jumps - you can use UIS (User Input Service) or you can use humanoid.jump. I would recommend using UIS as it is faster but looking at your script I think you should use humanoid.Jump.

Heres how to fix your script.

humanoid.Jumping:Connect(function(jump)
  if jump == true then
    if not jumpAnimeTrack.IsPlaying then
       jumpAnimTrack:play()
    end
  else
    if jumpAnimeTrack.IsPlaying then
      jumpAnimeTrack:Stop()
    end
  end
end)

Heres an article on humanoid.Jump:

https://developer.roblox.com/en-us/api-reference/event/Humanoid/Jumping

Any Questions? Just ask!

This discussion is preserved as it was. New answers, comments, and votes are closed.