'How to fix this error: attempt to index a number value in Lua Script
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
Solution 1:[1]
You haven't told us the line, but there are only a few indexing operations:
developer:historicalMessage(...)andglobal:printMessage(...)are presumably not the cause. Ifdeveloperandglobalwere numbers, they could be however. That seems unlikely to me as they are being used as "method tables" though (probably with metatables).message.subsmight be indexing the numbermessageifdeveloper:historicalMessage(22)[1]is a number.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | LMD |


