UserInputService Holding for 10 seconds

Hello developers, can anyone help me with my script?

local Player = game.Players.LocalPlayer
local Tool = script.Parent
local GokuGUI = Player.PlayerGui:WaitForChild("Abilities").Goku

Tool.Equipped:Connect(function()
	GokuGUI.Visible = true
	Tool.Equip.Value = true
end)

Tool.Unequipped:Connect(function()
	GokuGUI.Visible = false
	Tool.Equip.Value = false
end)

local Character = Player.Character or Player.CharacterAdded:Wait()
local UIS = game:GetService("UserInputService")
local Mouse = Player:GetMouse()

local Ki_Bullet = game:GetService("SoundService").Ki_Bullet:Clone()
Ki_Bullet.Parent = Player.Character.RightHand
local Ki_BulletSound = Player.Character.RightHand:WaitForChild("Ki_Bullet")
local XCooldown = Player.PlayerGui.Abilities.Goku.XCoolDown
local ShotAnim = script.FireAnim
local ShotTrack = Character.Humanoid:LoadAnimation(ShotAnim)
ShotTrack.Priority = Enum.AnimationPriority.Action
local isCooldownActive = false
local Bullet = game:GetService("ReplicatedStorage").Bullet:Clone()
local KiEvent = game:GetService("ReplicatedStorage").KiShoot
local isShooting = false

UIS.InputBegan:Connect(function(input, Processed)
	if not Processed then
		if input.KeyCode == Enum.KeyCode.X and GokuGUI.Visible and Mouse.Target and not isCooldownActive then
			if not isShooting then
				isShooting = true
				ShotTrack:Play()
				Ki_BulletSound:Play()
				while isShooting do
					KiEvent:FireServer(Mouse.Hit.Position)
					wait(0.35)
				end
			else
				isShooting = false
				Ki_BulletSound:Stop()
				ShotTrack:Stop()
			end
		end
	end
end)

UIS.InputEnded:Connect(function(input, Processed)
	if not Processed then
		if input.KeyCode == Enum.KeyCode.X and GokuGUI.Visible then
			isShooting = false
			Ki_BulletSound:Stop()
			ShotTrack:Stop()
			if not isCooldownActive then
				isCooldownActive = true
				XCooldown.Visible = true
				XCooldown:TweenSize(UDim2.new(0, 0, 0.148, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 9.7, false)
				wait(9.7)
				XCooldown.Visible = false
				XCooldown.Size = UDim2.new(1, 0, 0.148, 0)
				isCooldownActive = false
			end
		end
	end
end)

So this script works with holding. When the player holds X, it will do an event, and when he stops holding, it will stop that event. So I need to know how I can add a timer so if the player holds X for more than 10 seconds, it will cancel the event so the player will not spam!