Idle Animation issues and Jumping Issue

I wanted to change the default idle animation but I went through a lot of issues and I am kind of lost right now. This is my first post here and im new so sorry if my formatting is bad.

The first things I tried to do was following this thread which also included a video. I followed the thread but after the animation finished it didn’t loop.

I saw another thread and got a looping idle animation localscript that worked:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local idleAnimation = Instance.new("Animation")
idleAnimation.AnimationId = "rbxassetid://4657922943"
local loadedAnimation = humanoid:LoadAnimation(idleAnimation)
loadedAnimation.Looped = true

humanoid.Running:Connect(function(speed)
	if speed > 0 
	and not jumping	
	then
		print ("RUNNING")
		loadedAnimation:Stop()
	elseif speed == 0 and not jumping then
		print("STOPPED")
		loadedAnimation:Play()
	
	end

end)

The idle animation did work and it was looping but I ran into another problem. When I was holding space to jump, the idle animation plays anyways.

To fix this, I added a variable so it would check if I was holding space before it was playing the animation:

-- Services
local UIS = game:GetService("UserInputService")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local idleAnimation = Instance.new("Animation")
idleAnimation.AnimationId = "rbxassetid://4657922943"
local loadedAnimation = humanoid:LoadAnimation(idleAnimation)
loadedAnimation.Looped = true
local jumping = false

humanoid.Running:Connect(function(speed)
	if speed > 0 
	and not jumping	
	then
		print ("RUNNING")
		loadedAnimation:Stop()
	elseif speed == 0 and not jumping then
		print("STOPPED")
		loadedAnimation:Play()
	
	end

end)

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Space then
		jumping = true
	end
end)

UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Space then
		jumping = false
	end
end)

It fixed itself and the idle animation didn’t play at all when I was jumping but I ran into another problem. When I land while I am holding space I will randomly move slightly to a random direction. There are also instances where I move very far and sometimes even off the baseplate.
Note: I am only holding space during this video.
Couldn’t upload video so I put it in Google Drive

Here is also my double jump localscript:

-- Services
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

--Player
local plr = game.Players.LocalPlayer
local HumanoidRootPart = plr.character:WaitForChild("HumanoidRootPart")
local Humanoid = workspace:WaitForChild(plr.Name).Humanoid
Humanoid.JumpPower = 100

--Variables
local dbDoubleJump = true
local dbJump = false

--Animation
local doubleJumpAnimation = Instance.new("Animation")
doubleJumpAnimation.AnimationId = "rbxassetid://05109822254"
local doubleJumpTrack = Humanoid:LoadAnimation(doubleJumpAnimation)

local firstJumpAnimation = Instance.new("Animation")
firstJumpAnimation.AnimationId = "rbxassetid://05109816805"
local firstJumpTrack = Humanoid:LoadAnimation(firstJumpAnimation)

Humanoid.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Landed then
	print("FIRSTJUMP")
	dbDoubleJump = true
	dbJump = false
	end
end)

Humanoid.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.Jumping then
	firstJumpTrack:Play()
	end
end)

-- Check if space and flags are true
UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Space and dbDoubleJump and dbJump then
		Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
		doubleJumpTrack:Play()
		print("DOUBLEJUMP")
		dbDoubleJump = false
	end
end)

-- Check if Space is released
UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Space then
	dbJump = true
	end
end)
1 Like

If you want to change the default roblox animations, you want to run the game, go into your character and pull the animation script, and then put it into StarterCharacterScripts. After doing this, change the animation id’s in the script and the settings (it might be named something other than this, but it is a descendant of the Animation script). After doing this, you will be able to change any of the default roblox scripts.

By doing this, you will be able to still override animations with other scripts, so long as you set the AnimationPriority to be lower than (in your case) the double jump animation.

2 Likes

As I have put in the thread,

that was my first solution but the idle animation wasn’t looping. After the animation was finished, there would be no animation and it would just stand there not moving.

This seems to be an issue with the initial creation of the animation or your alteration of the default scripts. Though, I could be wrong. Did you set the animation to Loop when you created it? It does not make sense that the animation wouldn’t loop otherwise, assuming you did what I said properly.

2 Likes

That might be the solution. I am collaborating with my friends and I just receive the animations they give me. I see that there is an option to make it loopable in the animation editor but I thought all of these properties like being loopable was up to the AnimationTrack. Which would be in the default animation localscript but I don’t understand why the idle animation track wouldn’t be looped. I was trying to look at the default animation script that comes onto the character but I get lost very quickly and saw it wouldn’t be simple to change the animation tracks that were inside the script. That was why I got lost.

I will make the animation loop in animation editor and follow you back with what happens. Thanks.

I think I know why, you should do this for your idle anim:

script.Parent.Unequipped:Connect(function()
animation:Stop()
mywalkingidle:Stop()
value = false
connection:Disconnect() – this will disconnect so it won’t play when it is unequipped
end)
end)
connection = humanoid:GetPropertyChangedSignal(“Jump”):Connect(function()
animation:Stop()
mywalkingidle:Stop()
value = false
wait(.5)
value = true
print(“player is jumping”)
end)

(Change the variables or names according to your script.)

this is the key function btw if you want to know what function to check if player is jumping: humanoid:GetPropertyChangedSignal(“Jump”):Connect(function()

As @briact said - edit the animation in the editor and change it to looped, also make sure the Animation Priority is set to Idle (also can be changed in the animation editor), that way the jump animation will have priority if it’s Animation Priority is set to movement or action.