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

Why doesn't my sword script play animations?

Asked by 6 years ago

The script actually works but doesn't play animations

--//Variables
local plr = game.Players.LocalPlayer
local tool = script.Parent.Parent
local handle = tool:WaitForChild("Handle")
local blade = tool:WaitForChild("Blade")
local config = tool:WaitForChild("Configuration")
local dmg = config:WaitForChild("Damage")
local setdmg = config:WaitForChild("Dmg")
local idle = config:WaitForChild("Idle")
local cooldown = config:WaitForChild("CoolDown")
local altdmg = config:WaitForChild("AltDmg")
local altcooldown = config:WaitForChild("AltCoolDown")
--//Animations
repeat wait() until plr.Character.Humanoid
local AnimFolder = script.Parent.Parent:WaitForChild("Animations")
local slash = plr.Character.Humanoid:LoadAnimation(AnimFolder:WaitForChild("Slash"))
local hold = plr.Character.Humanoid:LoadAnimation(AnimFolder:WaitForChild("Hold"))
local altslash = plr.Character.Humanoid:LoadAnimation(AnimFolder:WaitForChild("AltSlash"))
hold.Looped = true

tool.Equipped:connect(function(mouse)
    hold.Looped = true
    hold:play()
mouse.Button1Down:connect(function()
        hold.Looped = false
        slash:Play()
        dmg.Value = setdmg.Value
        script.Parent.CoolDown.Disabled = false
        script.Disabled = true
    end)
mouse.Button2Down:connect(function()
        hold.Looped = false
        altslash:play()
        dmg.Value = altdmg.Value
        script.Parent.AltDown.Disabled = false
        script.Disabled = true
    end)
end)

tool.Unequipped:connect(function()
    hold.Looped = false
end)

Answer this question