Change idle animation in script

I want to change animation instantly using scripting without needing to walk.
You can see the issue in a video here.
Look at output too

This is the script that I have tried.:

local ReplicatedStorage = game:GetService("ReplicatedStorage");

local Character = game:GetService("Players").LocalPlayer.Character;

local Debounce = false;

game:GetService("UserInputService").InputBegan:Connect(function(Input, Process)
	if Input.KeyCode == Enum.KeyCode.E then
		if Debounce == false then
			Debounce = true;
			Character:WaitForChild("Animate"):WaitForChild("idle"):WaitForChild("IdleAnim").AnimationId = "rbxassetid://11484555705";
			print("Changed Animation");
		else
			Debounce = false;
			Character:WaitForChild("Animate"):WaitForChild("idle"):WaitForChild("IdleAnim").AnimationId = "http://www.roblox.com/asset/?id=507766388";
			print("Reverted");
		end
	end
end)

If this is not clear, you can ask me more at comment.

1 Like

i think that you can make the player plays the idle animation, something like this:

local animation = Instance.new('Animation', ...)
local animator = playerHumanoid.Animator

animation.AnimationId = 'rbxassetid://' -- your idle id

animation = animator:LoadAnimation(animation)
animation:Play()

OBS: Don’t put the animation looped! May cause some bugs on walking.

3 Likes

Just Copy the Animate from the Player and put it into StarterCharacterScripts (Get it while testing)

Example of my Character while testing:
Screenshot (51)

After placing your LocalScript safely outside of testing,
Change it to your desired Animation within the Values: (In your case: Idle)
Screenshot (52)

Screenshot (53)


So when testing, there wont be duplicates of Animate thankfully!

I hope this helps.

1 Like

Thank you for your comment, but this is not what I meant. I meant that Idle animations only played when tools were equipped.

Seriously? You wanted to make tool or what?

1 Like

Yes! I want to make when I equip a tool and change idle animation