我碰到下面的错误在我的Lua代码:错误:尝试索引字段'?' (一个零值)
attempt to index field '?' (a nil value)
它大胆发生在该线下方。我该如何解决它?
function SendMessageToAdmins(color1, color2, color3, msg)
for i = 0, maxSlots - 1 do
if Account[i] and Account[i].Admin >= 1 or Account[i] and Account[i].GameMaster >= 1 then
SendPlayerMessage(i, color1, color2, color3, string.format("%s", msg))
end
end
end
很难要知道为什么会发生此错误,而不知道“Account”来自何处以及它期望包含哪些内容。 –
可能是(元)表。这似乎是一个全局变量。也许你把它指定为本地不正确? –
请阅读[*此*](http://stackoverflow.com/questions/how-to-ask) – alfasin