Tool animation not working

I made an animating script which should play when my tool gets equipped, but it doesn’t work they are no errors sorry if the mistake is silly, I haven’t coded in a few years

local player = game:GetService("Players").LocalPlayer
local anims = script.Parent.Hold
local loadedAnims
local tool = script.Parent
local Animator

tool.Equipped:Connect(function()
   Animator = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
   loadedAnims = Animator:LoadAnimation(anims)
   loadedAnims:Play()
end)

tool.Unequipped:Connect(function()
   loadedAnims:Stop()
end)
4 Likes

animation must have animation priority set to movement or action

2 Likes

You might need to set the animation priority to action to override the default equip animation.

2 Likes

the priority is set to action but it still wont work

1 Like

You could send a remote event to the server and weld the tool to the animation part, and break the weld when you unequip

1 Like

I’d send an example but im on my mobile right now.

1 Like

seems like you are trying to load the animation from the client + the script is inside the tool
when the tool is equipped, the tool is inside the character so you don’t need to get the character from the local player


local anims = script.Parent.Hold
local loadedAnims
local tool = script.Parent
local Animator
local player 

tool.Equipped:Connect(function()
   player = tool.Parent
   Animator = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
   loadedAnims = Animator:LoadAnimation(anims)
   loadedAnims:Play()
end)

tool.Unequipped:Connect(function()
   loadedAnims:Stop()
end)
2 Likes

but would that change anything?

i suppose you can’t load an animation from the client
turn this script to a server script the script edits ive provided should work (or not)

alr i will try converting the script to server side

It didnt work in server side

@Mister33j

I tried u script now it gave me a error lol

I fixed it tho but it still dont work

very curious about what the error is
or ima just do something stupid, try this lol

tool.Equipped:Connect(function()
   repeat wait() until tool.Parent:IsA("Model") or tool.Parent:FindFirstChildOfClass("Humanoid") --choose either agurement
   Animator = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
   loadedAnims = Animator:LoadAnimation(anims)
   loadedAnims:Play()
end)

2 errors.

i think the issue is the animation itself not the script

what are the errors in the output

 Stack Begin  -  Studio
  13:48:15.067  Script 'Players.ZINTICK.Backpack.Tool.Script', Line 9  -  Studio - Script:9
  13:48:15.067  Stack End  -  Studio
  13:48:15.325  Players.ZINTICK.Backpack.Tool.Script:15: attempt to index nil with 'Stop'  -
13:48:15.325  Stack Begin  -  Studio
  13:48:15.325  Script 'Players.ZINTICK.Backpack.Tool.Script', Line 15  -  Studio - Script:15
  13:48:15.326  Stack End  -  Studio
  13:48:15.583  Character is not a valid member of Backpack "Players.ZINTICK.Backpack"

I think my script is good but i think the issue is the anim idk what tho

my bad my bad my bad i had errors there

tool.Equipped:Connect(function()
   repeat wait() until tool.Parent:IsA("Model") or tool.Parent:FindFirstChildOfClass("Humanoid") --choose either agurement
   Animator = player:WaitForChild("Humanoid"):WaitForChild("Animator")
   loadedAnims = Animator:LoadAnimation(anims)
   loadedAnims:Play()
end)
1 Like

how do u take screen shots???

@Mister33j it doesnt work

why am i this braindead today PLEASE HELP

tool.Equipped:Connect(function()
   repeat wait() until tool.Parent:IsA("Model") or tool.Parent:FindFirstChildOfClass("Humanoid") --choose either agurement
   player = tool.Parent
   Animator = player:WaitForChild("Humanoid"):WaitForChild("Animator")
   loadedAnims = Animator:LoadAnimation(anims)
   loadedAnims:Play()
end)