Having string match with "a" or "an" as required

I’m trying to make an automated message for when a player requires a specific tool, at the moment I have “Fishing Rod” or “Axe”. My problem is, the message will say
You need to be holding a Axe
which is not grammatically correct.
So I was wondering if there was a clear way to check if I need to use “a” or “an”

I am aware an is used before vowel starting words, a for consonant starting words, but I’m unsure how to detect this is a clean (ideally) single line code

I DO NOT want to just do

if tool == "Fishing Rod" then
elseif tool == "Axe" then

as this is not expandable. It needs to be future proof and work across all possible words.

use string.sub and string.split for this.

local sl = string.sub(string.split(tool, " ")[1], 1, 1)
local vowels = {"a", "e", "i", "o", "u"}

if table.find(vowels, sl) then
1 Like