Hi, I’m trying to make a 3-hit combo sword where the user could either swing once, twice or 3 times, kind of like making a combo. The problem is that the scripts are starting to confuse me and it kind of makes the animation a bit “twitchy” and I don’t want that. Can someone help me simplify my script so I could understand better? I also wanna know if you can cancel a part of your script and simply go straight to the other part once you click again since I’m using booleans in order to check if it should do that or not.
tool.Equipped:Connect(function() --just adds the motor6d and removes the gear grip, yadeyadeda
character["Right Arm"]:WaitForChild("RightGrip"):Destroy()
local motor6d = Instance.new("Motor6D",character["Right Arm"])
motor6d.Name = "HandleMotor6D"
motor6d.Part0 = character["Right Arm"]
motor6d.Part1 = tool.Handle
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://5074975163"
animtrack = character.Humanoid:LoadAnimation(animation) --idle animation
animtrack:Play()
debounce = true --this is the boolean which is the sword cooldown so basically what starts the 3 combo
swing2accepted = false --checks if clicked again to perform second swing, youll see why at the main script
swing3accepted = false --this one aswell
end)
tool.Activated:Connect(function()
local animation2 = Instance.new("Animation")
animation2.AnimationId = "rbxassetid://5075007022"
local animtrack2 = character.Humanoid:LoadAnimation(animation2) --first swing animation
local animation3 = Instance.new("Animation")
animation3.AnimationId = "rbxassetid://5313299007"
local animtrack3 = character.Humanoid:LoadAnimation(animation3) --second swing animation
local animation4 = Instance.new("Animation")
animation4.AnimationId = "rbxassetid://5313346478"
local animtrack4 = character.Humanoid:LoadAnimation(animation4) --third swing animation
if swing3 == true then
swing3 = false
swing3accepted = true
animtrack:Stop()
animtrack3:Stop()
animtrack4:Play()
wait(2)
animtrack4:Stop()
animtrack:Play()
wait(1)
debounce = true
elseif swing2 == true then
swing2 = false
swing2accepted = true
animtrack2:Stop()
animtrack3:Play()
wait(0.75)
swing3 = true
wait(0.5)
swing3 = false
wait(0.75)
if swing3accepted == true then
return
else
animtrack3:Stop()
animtrack:Play()
wait(1)
debounce = true
end
elseif debounce == true then
debounce = false
animtrack:Stop()
animtrack2:Play()
wait(0.75)
swing2 = true
wait(0.5)
swing2 = false
wait(0.75)
if swing2accepted == true then
return
else
animtrack2:Stop()
animtrack:Play()
wait(1)
debounce = true
end
end
end)
If you need clarification, ask me.