Animation Problem

As I’ve taken a big break from scripting, I have gotten a little bit rusty.

Basically, my walk animation and my knife animation isn’t playing at all. I’ve tried countless fixes for this and I’ve scowered all over the internet but to no avail. I am absolutely clueless to what’s going on and I would like some help on this.

Local script for walking animation(Yes, I have 2 scripts as I’ve done it on both client and server to see if it works)
This local script is located in StarterCharacterScripts

local char = game.Players.LocalPlayer.Character
local animate = char:WaitForChild("Animate")
animate.run.RunAnim.AnimationId = "rbxassetid://10498720243"        
animate.walk.WalkAnim.AnimationId = "rbxassetid://10498720243"

Server Script(aka. my second attempt into getting a working walk animation)

This server script is located in Server Script Service

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
		local animate = char.Animate
		animate.run.RunAnim.AnimationId = "rbxassetid://10498720243"        
		animate.walk.WalkAnim.AnimationId = "rbxassetid://10498720243"      
		end)
end)

Now, this is my knife slashing script:

This is a local script located in StarterPack, Knife Tool:


script.Parent.Activated:Connect(function()

print("a")

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

print("b")

local animator = char:WaitForChild("Humanoid"):WaitForChild("Animator")

print("no")

local animation = workspace:WaitForChild("KnifeSwing")

print("ye")

local loadanimation = animator:LoadAnimation(animation)

print("pls")

loadanimation:Play()

print("worked")

task.wait(0.15)

loadanimation:Stop()

print("indeed")

end)

I would honestly love some help on this as once again, I am clueless on what’s happening.

local Animation = Instance.new("Animation")
 Animation.AnimationId = "Your animation here" 
local asdf = Animator:loadAnimation(Animation) 
asdf:Play()```

this is what I use, sorry this isn't much help I'm a bit rusty too

Unfortunately still doesn’t work, I’m baffled if I’m being honest with you.

I would personally reference the animation and character out of the Tool.Activated function. I would also put the animation under the script. It would look somewhat like this:


local char = game:GetService("Players").LocalPlayer.Character
local animator = char:WaitForChild("Humanoid"):WaitForChild("Animator")
local animation = animator:LoadAnimation(script.Animation) -- REMEMBER TO PUT ANIMATION UNDER SCRIPT

script.Parent.Activated:Connect(function()
    animation:Play()

    task.wait(0.15)

    animation:Stop()
end)

this probably won’t fix it, but it would be a lot cleaner. If it still doesn’t work see if it returns any errors and reply to this, thanks.

When I do that, this error pops up:

Which line of code corresponds to the error code?

Line 4 creates the error shown.

You need to provide us with line 4 as we don’t know what it is on your script.

Ah sorry, thought I already provided it.

Here you go:

local plr = game.Players.LocalPlayer
local char = plr.Character
print("b")
local animator = char:WaitForChild("Humanoid"):WaitForChild("Animator")
print("no")
local Animation = Instance.new("Animation")
script.Parent.Activated:Connect(function()
		print("a")
		Animation.AnimationId = "rbxassetid://10498835413" 
		Animation.Parent = script
		local loadanimation = animator:LoadAnimation(Animation)
		local load = animator:loadAnimation(Animation) 
		loadanimation:Play()
	print("worked")
	end)

Sorry for the late reply, I was sleeping.

This should fix the error, the localscript ran before the character was loaded into workspace.

local plr = game.Players.LocalPlayer
repeat wait() until plr.Character -- Waits until the character has loaded into workspace.
local character = plr.Character

print("b")
local animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
print("no")
local Animation = Instance.new("Animation")
script.Parent.Activated:Connect(function()
	print("a")
	Animation.AnimationId = "rbxassetid://10498835413" 
	Animation.Parent = script
	local loadanimation = animator:LoadAnimation(Animation)
	local load = animator:loadAnimation(Animation) 
	loadanimation:Play()
	print("worked")
end)

I’ve tried this and same outcome, animation doesn’t play at all despite it printing worked.

It is because you loaded a new 2nd animation to the humanoid, where the first one wouldn’t work.
I just tested with one my animations and it worked.

This is the working code, I removed line 14 which was local load = animator:loadAnimation(Animation)

local plr = game.Players.LocalPlayer
repeat wait() until plr.Character -- Waits until the character has loaded into workspace.
local character = plr.Character

print("b")
local animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
print("no")
local Animation = Instance.new("Animation")
script.Parent.Activated:Connect(function()
	print("a")
	Animation.AnimationId = "rbxassetid://10498835413" 
	Animation.Parent = script
	local loadedAnimation = animator:LoadAnimation(Animation)
	loadedAnimation:Play()
	print("worked")
end)

I am puzzled, still doesn’t play.

Since this is a tool animation, has the the animation Priority set to Action?

I have tested it with R15 & R6 animations, they both worked. I can’t see the problem currently.

I have set the priority to action as one of my attempts to get it working. I will check again though.

image

I already set it on action

Have you overwritten that version to the roblox website with the current animation that is on the website?

I haven’t overridden it(since I don’t know how to) but I have created an entirely new animation and changed the script to have the new animations id. No luck still. Maybe its only playing on the server? But I’m using a local script.

Could you send the animation in a .rbxm file so I could look at it too see if I can find a issue in the animation itself? If not I could try and create a tool animation in R6/R15.

toolanim.rbxm (1.5 KB)
Heres the animation

I reuploaded the animation to my profile so I can use it, since roblox doesn’t allow you to use others animations.

The outcome was this:
https://gyazo.com/f44877410be8f8587b7f04662c3dd800

It was working, I’m not sure what is happening on your end.