I'm learning Lua but I got this error attempt to index a number value when compiler reach this piece of code
if a() == -1 then
return code
end
Console Error
i tried to change the type of return from number to boolean but i got the same error
Boolean console error
function a()
local message = developer:historicalMessage(22)
if message == nil or message[1] == nil then return nil end
message = message[1]
if message.subs == 0 then
global:printMessage("Here !")
return -1
end
end
function Notif()
if a() == -1 then
return code
end
end
CodePudding user response:
You haven't told us the line, but there are only a few indexing operations:
developer:historicalMessage(...)
andglobal:printMessage(...)
are presumably not the cause. Ifdeveloper
andglobal
were numbers, they could be however. That seems unlikely to me as they are being used as "method tables" though (probably with metatables).message.subs
might be indexing the numbermessage
ifdeveloper:historicalMessage(22)[1]
is a number.