Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why Isn't my Idle animation for my tool not playing?

So I typed this script with Animator:

local Tool = script.Parent
local Animation = Tool:WaitForChild("Animation")
local Animator = Instance.new("Animator")

Animator.Parent = Animation

local AnimationTrack

Tool.Equipped:Connect(function()
	local Character = Tool.Parent
	local Humanoid = Character.Humanoid
	
	AnimationTrack = Humanoid:WaitForChild("Animator"):LoadAnimation(Animation)
	AnimationTrack:Play()
end)

Tool.Unequipped:Connect(function()
	AnimationTrack:Stop()
end)

But It doesn't work, I suck at using animator (Because Im new to It) and doesn't know what to do

1 answer

You don't have to create a new animator, humanoid already has an animator when it first adds

local Tool = script.Parent
local Animation = Tool:WaitForChild("Animation")
local Animator 

Animator.Parent = Animation

local AnimationTrack

Tool.Equipped:Connect(function()
	local Character = Tool.Parent
	local Humanoid = Character.Humanoid
        Animator = Humanoid.Animator -- Get Animator instance
	AnimationTrack = Humanoid:WaitForChild("Animator"):LoadAnimation(Animation)
	AnimationTrack:Play()
end)

Tool.Unequipped:Connect(function()
	AnimationTrack:Stop()
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.