Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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

Log in to vote
0
Answered by
SuperPuiu 497 Moderation Voter
2 years ago

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)
Ad

Answer this question