Animation script is not working

Hi,
I’m a scripter, I’m working on big projects and they’ll be out soon! I’m making a tool that I want to animate, but I’m having a problem with it

Issue:

I have an Animation script inside a tool that’s in StarterPack, but the script isn’t working.

This is where my Tool is and what it contains:

image

here is the error I get on the output:

I have tried different ways of the scripts, I also tried to put a script inside the StarterCharacterScript, the
StarterCharacterScript doesn’t give me any errors but it doesn’t work, and for the script inside the tool it gives me the error above.

I also tried Humanoid.Animator:LoadAnimation like in the script but it doesn’t work and it gives me an error saying attempt to index nil with ‘Humanoid’

Scripts:

local Player = game.Players.LocalPlayer 
local Character = Player.Character
local Animation = script.Parent:WaitForChild("Attack")
local AttackAnim = Character.Humanoid.Animator:LoadAnimation(Animation)

script.Parent.Activated:Connect(function()
	AttackAnim:Play()
end)

I hope you can help me

Shieldmr.

1 Like

Attempt to index nil with humanoid means your character is nil. Try this:

local Player = game.Players.LocalPlayer 
local Character = Player.Character or Player.CharacterAdded:Wait()
local Animation = script.Parent:WaitForChild("Attack")
local AttackAnim = Character:WaitForChild("Humanoid"):LoadAnimation(Animation)

script.Parent.Activated:Connect(function()
	AttackAnim:Play()
end)
2 Likes

Thank you for your answer!
It gave me an error:

1 Like

You will need to wait for the characters parts, if the character model has just spawned it it may be lacking some parts temporarily.

Just do Character:WaitForChild(“Humanoid”)

This way if the client is running slow and not loading fast enough the script wont be stopped.

2 Likes

try that i edited it
hihihihihihihi

2 Likes

It didn’t work for some reason! But it gave me no error.

It gave no errors but the animation is not working for some reason!

@http_shawn
@minimic2002

I found out that the animation only worked for R6, sorry for wasting your time!
Thank you all for your help!