Animate Script Help (Walk,Jump,Idle)

  1. What do you want to achieve?

Simple Walk,Idle, and Jump animation that works for a certain Character Rig of mine.

  1. What is the issue?

Idle, Walk anim work, but when a player jumps, it either stops all animations, or starts walking even when they are not moving.

Take a look at this topic : Walking Animation Playing When Not Supposed To

https://gyazo.com/980e31ac212a13752386babd0868d80f

  1. What solutions have you tried so far?

I tried fixing -

humanoid.Jumping:Connect(function()
	walkAnimTrack:Stop()
	jumpAnimTrack:Play()
end)

to

humanoid.Changed:connect(function()
	if humanoid.Jump then
		jumpAnimTrack:Play()
	end
end)

But it still doesn’t make a difference.

Here is the full code:

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local jumpSound = script:WaitForChild("JumpSound")

local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)
walkAnimTrack.Priority = Enum.AnimationPriority.Movement

local idleAnim = script:WaitForChild("Idle")
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)
idleAnimTrack.Priority = Enum.AnimationPriority.Idle

local jumpAnim = script:WaitForChild("Jump")
local jumpAnimTrack = humanoid.Animator:LoadAnimation(jumpAnim)
jumpAnimTrack.Priority = Enum.AnimationPriority.Action

humanoid.Running:Connect(function(speed)
	if speed > 0 then
		if not walkAnimTrack.IsPlaying and idleAnimTrack.IsPlaying then
			idleAnimTrack:Stop()
			walkAnimTrack:Play()
		end
	else
		if walkAnimTrack.IsPlaying and not idleAnimTrack.IsPlaying then
			idleAnimTrack:Play()
			walkAnimTrack:Stop()
		end
	end
end)

--humanoid.Jumping:Connect(function()
--	walkAnimTrack:Stop()
--	jumpAnimTrack:Play()
--	jumpSound:Play()
--	wait(0.5)
--	jumpAnimTrack:Stop()
--	idleAnimTrack:Play()
--end)

humanoid.Changed:connect(function()
	if humanoid.Jump then
		jumpAnimTrack:Play()
	end
end)


idleAnimTrack:Play()

Could it be because of the speed > 0 ?

If I do

humanoid.Changed:connect(function()
	if humanoid.Jump then
		jumpAnimTrack:Play()
		jumpSound:Play()
		wait(0.5)
		jumpAnimTrack:Stop()
		idleAnimTrack:Play()
	end
end)

It works normally, but then breaks the idle animation to where it doesn’t even work anymore.

2 Likes

maybe this tutorial might hell you

1 Like

If you are using Humanoids (which I assume you are) I would use humanoid descriptions to accomplish this!

https://developer.roblox.com/en-us/articles/humanoiddescription-system

1 Like

I’m very new with the humanoid descriptions.

I insert my humanoid description into the [Template] model of the Bloxikin form correct? Then just change the animation ids, and it works?

you may have to use Humanoid:ApplyDescription() to actually set it.

1 Like

To anyone who has had this problem,

I found the solution.


Using my brain, I finally was able to figure out that the ‘‘Humanoid.Running’’ was the problem this whole time.

Here is the fix!

local RunService = game:GetService("RunService")

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local jumpSound = script:WaitForChild("JumpSound")

local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)
walkAnimTrack.Priority = Enum.AnimationPriority.Movement

local idleAnim = script:WaitForChild("Idle")
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)
idleAnimTrack.Priority = Enum.AnimationPriority.Idle

local jumpAnim = script:WaitForChild("Jump")
local jumpAnimTrack = humanoid.Animator:LoadAnimation(jumpAnim)
jumpAnimTrack.Priority = Enum.AnimationPriority.Action

idleAnimTrack:Play()

local function move()
   
   if humanoid.MoveDirection.Magnitude > 0 then
   	if not walkAnimTrack.IsPlaying and idleAnimTrack.IsPlaying then
   		idleAnimTrack:Stop()
   		walkAnimTrack:Play()
   	end
   else
   	if walkAnimTrack.IsPlaying and not idleAnimTrack.IsPlaying then
   		idleAnimTrack:Play()
   		walkAnimTrack:Stop()
   	end
   end
   
   if humanoid.Jump then
   	jumpAnimTrack:Play()
   	jumpSound:Play()
   end
   
end


RunService.RenderStepped:Connect(move)
2 Likes