--Variables
local Player = game.Players.LocalPlayer
local Char = Player.Character
local Tool = script.Parent
local SwingSound = Tool:WaitForChild("HitSound")
local CanAttack = Tool:WaitForChild("CanAttack")
local Remote = game.ReplicatedStorage:WaitForChild("Combat")
local HitBox = Tool:WaitForChild("HitBox")
--Tool Equip Function
Tool.Equipped:Connect(function()
local Idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
Idle:Play()
end)
--Tool Activated Function
Tool.Activated:Connect(function()
local Combo = 1
CanAttack.Value = true
if Combo == 1 then
local Combo1Anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Combo1)
SwingSound:Play()
Combo1Anim:Play()
Combo = 2
elseif Combo == 2 then
local Combo2Anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Combo2)
SwingSound:Play()
Combo2Anim:Play()
Combo = 3
elseif Combo == 3 then
local Combo2Anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Combo3)
SwingSound:Play()
Combo3Anim:Play()
Combo = 4
elseif Combo == 4 then
local Combo2Anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Combo4)
SwingSound:Play()
Combo4Anim:Play()
Combo = 5
elseif Combo == 5 then
local Combo2Anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Combo5)
SwingSound:Play()
Combo5Anim:Play()
Combo = 6
elseif Combo == 6 then
local Combo2Anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Combo6)
SwingSound:Play()
Combo6Anim:Play()
Combo = 1
end
end)
--Tool Unequip Function
Tool.Unequipped:Connect(function()
local Hum = Char:WaitForChild("Humanoid")
for _,anim in pairs(Hum:GetPlayingAnimationTracks()) do
anim:Stop()
end
end)
Above is my local script for an attack tool. I have found 3 issues.
- In my script I have specified at the end of each if/ elseif it changes the value of the combo, so when the tool is activated again, it will play a different animation in the combo chain. This doesn't seem to be working however, I tested and the combo value stays at 1.
- I don't know how to add a cooldown for the attacks, so I can just spam click the attack and it will play on rapid fire.
- When my tool equips it plays a looping animation to show its equipped, and there's a function to stop all animations when the tool is unequipped. This also doesn't seem to be working.
I'm very new to scripting and don't have that much understanding so I would appreciate if someone could fix my script or tell me how to fix it. Thanks!

1 comment
Thanks for the help but it doesn't seem to work ):