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)

3 comments

0

I wouldn't say this fixes it but Activated functions usually have to go below the Equipped function.

0

When connecting events, the order in which they occur typically doesn't matter.

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.