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

My script doesn't stop an animation, any solution?

Asked by 6 years ago

The function at the end actually doesn't work? It doesn't stop playing a hold animation, any fix?

--//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")
--//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"))
hold.Looped = true

tool.Equipped:connect(function()
    hold:play()
end)

tool.Activated:connect(function()
    slash:Play()
    dmg.Value = setdmg.Value
    hold:stop()
    script.Parent.CoolDown.Disabled = false
    script.Disabled = true
end)

tool.Unequipped:connect(function()
    hold:stop()
end)
0
I wouldn't say this fixes it but Activated functions usually have to go below the Equipped function. User#18043 95 — 6y
0
When connecting events, the order in which they occur typically doesn't matter. XAXA 1569 — 6y
0
Anyway, it's possible that hold has a higher priority than slash. You also probably don't have to stop the hold animation in your activated function if slash has a higher priority than hold. XAXA 1569 — 6y

Answer this question