ok so my animation is not playing when i equip a tool and i click, i want a animation to play, yet it isnt, any reason why?
local Players = game:GetService("Players") script.Parent.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() local Players = game:GetService("Players") local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) wait(1.2) animation:Play() end) end)
Why are you waiting for wait(1.2)?
Just play the animation right after:
local Players = game:GetService("Players") local animation = game.Players.LocalPlayer:WaitForChild("Character"):WaitForChild("Humanoid"):LoadAnimation(script.Parent.Animation) script.Parent.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() local Players = game:GetService("Players") animation:Play() end) end)
Also make your animation priority in the editor to action: other action animations will still override this, so its safe to set equip (and other things) animations to action
EDIT: i fixed so it waits for the humanoid
****Try changing
game.Players.LocalPlayer.Character.Humanoid
to this
game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
****Update
Your problem may be the fact that this script is running before your character has loaded.
So, you would do something like this :
local player = game.Players.LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local hum = char:WaitForChild('Humanoid') local animation = hum:LoadAnimation(script.Parent.Animation) script.Parent.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() wait(1.2) animation:Play() end) end)
thanks for your help everyone i finally found out the reason why it wasnt working, i was in r15, the animation was for only r6, thank you to those who helped!