You have a scoping problem.
Code:
for k, v in pairs(flasks) do
local flask = UnitBuff("player", k)
-- "flask" is local to this scope.
end
-- "flask" does not exist in this scope.
if (not isGuildGroup and food) or (isGuildGroup and flask and food) then
ReadyCheckFrame:Hide()
ConfirmReadyCheck(1)
end
Also, you may want to change your
GetSpellName function to return an empty string, or UNKNOWN, or some other "dummy" value for spell IDs that don't return a real name. Otherwise, if Blizzard changes a spell ID, you will end up with holes in your otherwise sequentially-indexed table.
Also also, since you
are using an indexed table, you should use
for i = 1, #flasks do local k = flasks[ i ] instead of
for k, v in pairs(flasks) to avoid the slow call to
pairs.