#sword animation wont work

1 messages · Page 1 of 1 (latest)

tame abyss
#
local Character = Player.Character or Player.CharacterAdded:Wait()

local Tool = script.Parent
local Animation = script.Animation

local Humanoid = Character:WaitForChild("Humanoid")

local AnimationIds = {
    "http://www.roblox.com/asset/?id=656118852"
}

local Tracks = {}

for Index, AnimationId in pairs(AnimationIds) do -- converting all the animation ids to loaded animations or track
    Animation.AnimationId = AnimationId
    Tracks[Index] = Humanoid:LoadAnimation(Animation)
    local CurrentTrack = Tracks[Index]
    CurrentTrack.Priority = Enum.AnimationPriority.Action -- Highest Priority
end

local function OnEquipped() -- plays only the first track arranged base on the animation ids
    Tracks[1]:Play()
end

local function OnUnequipped() -- on this function it will stop all the stored tracks when the tool is unequipped as the event triggers it
    for _, Track in pairs(Tracks) do
        if Track.IsPlaying then
            Track:Stop()
        end
    end
end)

Tool.Equipped:Connect(OnEquipped)
Tool.Unequipped:Connect(OnUnequipped)

tool.Equipped:Connect(function()
    print("Equipped")
    
end)
    
    tool.Unequipped:Connect(function()    
    print ("Unequipped")     

end)```
this is like the first thing ive tried to script (80% of the code is forked🥀) but the whole script breaks, what did i do wrong