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

Animation won't load? [Attempt to make multiple animations for one task]

Asked by
Clorize 31
4 years ago

So I'm trying to make a knife [Haven't gone to damaging yet] and I've thinking of giving multiple animations to make it look more lively. But the issue is, whenever I attempt to make the system like this, it breaks and none of the animations load. I do believe I've named and placed everything in the right spot tho.

local tool = script.Parent
local debounce = false
local equipsound = tool.Sounds.Equip
local slashsound = tool.Sounds.Slash
local prevanim = tool.Values.previousAnimation
local chosenanim = tool.Values.previousAnimation
prevanim = 1
chosenanim = 1

tool.Equipped:Connect(function(Mouse)
        equipsound:Play()
        Mouse.Icon = "rbxasset://textures/GunCursor.png"
        local char = script.Parent.Parent
        local knifehold = char.Humanoid:LoadAnimation(script.Parent.Animations.KnifeHold)
        knifehold:Play()
        tool.Activated:Connect(function()
            if debounce == false then
                debounce = true
                slashsound:Play()
                while chosenanim == prevanim do
                    chosenanim = math.random(1,3)
                end
                prevanim = chosenanim
                local anim = script.Parent.Animations["Slash"..chosenanim]
                local slash1 = char.Humanoid:LoadAnimation(anim)
                slash1:Play()
                wait(0.5)
                debounce = false
            end
        end)
        tool.Unequipped:Connect(function()
            knifehold:Stop()
            Mouse.Icon = ""
        end)
end)

Answer this question