I have a Katana attack animation that is supposed to play when a player holds the “Q” key, plays the animation and freezes at a certain point, then when the Key “Q” is released, the animation continues to play. My issue is that if the key is pressed and released very quickly, my animation freezes (as shown in the video below). Any solutions provided are appreciated
--[[Services]]--
local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
--[[Variables]]--
local player : Player = game.Players.LocalPlayer
local character : Model = player.Character or player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
local Key : string = "Q"
local EquipKey : string = "E"
local Debounce = {}
local Debounce_Delay : number = 3
local Attacking = false
local Track : AnimationTrack
--[[Functions]]--
UIS.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then warn("typing") return end
if Input.KeyCode == Enum.KeyCode[Key]then
if Debounce[player.Name] == nil then
Debounce[player.Name] = true
if Attacking == false then
Attacking = true
end
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
Track = Humanoid:LoadAnimation(script.Animations.Attack1)
Track:Play()
Track:GetMarkerReachedSignal("freeze"):Connect(function()
Track:AdjustSpeed(0)
RS.Katana_Remotes.FreezeInit:FireServer()
end)
task.wait(Debounce_Delay)
Debounce[player.Name] = nil
Attacking = false
end
elseif Input.KeyCode == Enum.KeyCode[EquipKey] then
local Track : AnimationTrack = Humanoid:LoadAnimation(script.Animations.Equip)
Track:Play()
Track:GetMarkerReachedSignal("equip"):Connect(function()
RS.Sword_Remotes.Equip:FireServer()
end)
end
end)
UIS.InputEnded:Connect(function(Input, IsTyping)
if IsTyping then return end
if Input.KeyCode == Enum.KeyCode[Key] then
if Attacking == true then
Attacking = false
if Track then
Track:AdjustSpeed(1)
Track.Stopped:Wait()
Track:Stop()
end
end
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end
end)