Dribbling System

I’m trying to create a dribble system similar to that of other popular E to shoot basketball games. (i.e RB World 3, MyPark)

Here’s what I have so far:

function addDribbleToQueue(dribble)
	table.insert(queue, dribble)
end

function getNextDribbleFromQueue()
	return table.remove(queue,1)
end

coroutine.wrap(function()
	while wait() do
		if #queue > 0 and #queue <= 3 then
			if handling == true then
				print(queue[1])
				dribbledebounce = true
				task.wait(.35)
				getNextDribbleFromQueue()
				handling = false
				dribbledebounce = false
				if spinning then
					spinning = false
				end
			end
		end
	end
end)()

UIS.InputBegan:Connect(function(Input,IsTyping)
	if IsTyping then return end
	if script.HasBall.Value == true then
		if Input.KeyCode == Enum.KeyCode.Z then
			task.wait(.1)
			if recentKey == Enum.KeyCode.X then
				task.wait(.1)
				if recentKey == Enum.KeyCode.C then
					if script.Hand.Value == "Left" then
						if handling == true then
							repeat
								task.wait()
							until handling == false
						end
						spinning = true
						handling = true
						Handleevent:FireServer("Spin","Right")
					end
				else
					if script.Hand.Value == "Left" then
						if handling == true then
							repeat
								task.wait()
							until handling == false
						end
						handling = true
						Handleevent:FireServer("BehindTheBack","Right")
					end
				end
			else
				if spinning then return end
				if script.Hand.Value == "Left" then
					if handling == true then
						repeat
							task.wait()
						until handling == false
					end
					handling = true
					Handleevent:FireServer("Hesi","Left")
				elseif script.Hand.Value == "Right" then
					if handling == true then
						addDribbleToQueue("LeftCrossover")
					end
					handling = true
					Handleevent:FireServer("Crossover","Left")
				end
			end
		elseif Input.KeyCode == Enum.KeyCode.C then
			task.wait(.1)
			if recentKey == Enum.KeyCode.X then
				task.wait(.1)
				if recentKey == Enum.KeyCode.Z then
					if script.Hand.Value == "Right" then
						if handling == true then
							repeat
								task.wait()
							until handling == false
						end
						spinning = true
						handling = true
						Handleevent:FireServer("Spin","Left")
					end
				else
					if script.Hand.Value == "Right" then
						if handling == true then
							repeat
								task.wait()
							until handling == false
						end
						handling = true
						Handleevent:FireServer("BehindTheBack","Left")
					end
				end
			else
				if spinning then return end
				if script.Hand.Value == "Right" then
					if handling == true then
						repeat
							task.wait()
						until handling == false
					end
					handling = true
					Handleevent:FireServer("Hesi","Right")
				elseif script.Hand.Value == "Left" then
					if handling == true then
						addDribbleToQueue("RightCrossover")
					end
					handling = true
					Handleevent:FireServer("Crossover","Right")
				end
			end
		end
	end
end)

I honestly have no idea what I’m doing at this point so any help would be much appreciated.