Animation not working correctly?!

Im not sure where to put this but forgive me if I put it in the wrong category.

Now the thing is that as the title says my animation is not working correctly. The problem is that when I equip the tool I want it to play the animation but instead when I run the game it plays the animation after I equipped it.

Here is an video:

Hope you can help me!

37 Likes

can you show the script? i need more context

14 Likes
local player = game.Players.LocalPlayer

local animation = game.Workspace:WaitForChild(player.Name):WaitForChild("SwordAnimations").swordIdle
local humanoid = game.Workspace:WaitForChild(player.Name):WaitForChild("Humanoid")
local tool = script.Parent
local track = humanoid:LoadAnimation(animation)
tool.Equipped:Connect(function()
	track:Play()
end)

this is a localscript inside the tool

12 Likes

oh uhhh idk :'/

local player = game.players.localplayer
local character = player.character
local tool = script.parent

local anim = (animation directory)
local humanoid = character:waitforchild('humanoid')

local function onEquip()
local track = humanoid:loadanimation(anim)
track(play)
end

tool.Equipped:connect(onequip)
14 Likes

i think its your animation priority, you probably forgot to change it. i would recommend setting it to action.

14 Likes

I changed it to action and tried the idle but still the same results.

12 Likes

do you have a custom idle animation? (wait nvm)

12 Likes

oh its an idle animation? how many frames is it and do you have it set as looped? (sorry for not realizing haha, i thought you were trying to make an equip animation)

13 Likes

Its 1 frame cause I just want the arm to stay at that position with the sword for now. And I have set it looped in the animation editor but I don’t think that will cause it. But I will unloop it and see what happens.

13 Likes

no, its not that its looped. put it back on idle too. this is weird and it should work. let me think

12 Likes

also you know you can use player.Character right?

12 Likes

Maybe this helps coming up with an answer:

13 Likes

press the “loop button” first of all then make that the animation (set it to idle too)
image
also is this team create or are you creating it alone?
if its team create then did you create the animation?
also the method you use is deprecated so use this as seen here

local player = game.Players.LocalPlayer

local animation = game.Workspace:WaitForChild(player.Name):WaitForChild("SwordAnimations").swordIdle
local humanoid = game.Workspace:WaitForChild(player.Name):WaitForChild("Humanoid")
local tool = script.Parent
local track = humanoid:FindFirstChildOfClass("Animator"):LoadAnimation(animation)
tool.Equipped:Connect(function()
	track:Play()
end)
13 Likes

It is not team create. And its not the deprecated thing either cause it has still the same results.

11 Likes

i know its not cause its deprecated. but you should try to avoid using deprecated stuff. (example: instead of wait() do task.wait() )

12 Likes

but i really dont know what the problem is. it should work

13 Likes

I think I might know the problem ima see if it is.

EDIT: It didn’t solve it. I thought it might be because it is not my actual character but a model with the name StarterCharacter inside StarterPlayer.

10 Likes

Maybe it has something to do with the handle or grip?

12 Likes

What is the problem over here?

11 Likes

For the ones that try to help me here is some more information:

As soon as I press 1 to equip the tool the animation is being played. Atleast it calls the :Play() function.

But somehow the standard tool holding thing is being played. And then when I unequip the tool the animation is still playing but I can the arms.

So it has to be a problem with the tool itself. But I don’t know what.

11 Likes