If the player Holds V then the Heavy attack animation will play:
The Anim consisted of 2 parts, A charging part, and the actual slash
But I want it to skip to the actual slash animation if you released the heavy attack key mid-charge
(basically Elden Ring charge attack system)
This is the current script:
--Extracted script
local HeavyHeld = false
local PressedMouseButton = ""
UserInputService.InputBegan:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.V and Debounce == false then
PressedMouseButton = "HEAVY"
script.Parent:Activate()
HeavyHeld = true
print(PressedMouseButton)
end
end)
UserInputService.InputEnded:Connect(function(input, gpe)
if input.KeyCode == Enum.KeyCode.V then
PressedMouseButton = ""
HeavyHeld = false
end
end)
script.Parent.Activated:Connect(function()
if PressedMouseButton == "HEAVY" then
if Debounce == false then
--Absolutely no idea how to do this
end
end
end)
I would split the animation in two, a charge animation and an attack animation.
When the player starts holding the attack button, play the charge animation, then when the player lets go of the attack button OR the charge animation ends or reaches a certain time then play the attack animation.
elseif PressedMouseButton == "HEAVY" then
if Debounce == false then
Debounce = true
TimeHeavyPressed = time()
H1:Play()
repeat wait() until HeavyHeld == false or time() - TimeHeavyPressed >=1
local CancelWindow = time() - TimeHeavyPressed
if CancelWindow < 1 then
H1:AdjustSpeed(3) --sped up the anim until the slashing part
repeat wait() until H1.TimePosition > 1
H1:AdjustSpeed(1)
H1.TimePosition = 1
elseif CancelWindow >= 1 then
end
wait(0.75) -- cooldown
Debounce = false
end
end