
Received the following error: “attempt to call a number value near ‘for..in’”. After investigation, where vectors were assigned using getPosition(), getRotation() or getScale() and referred to using indices of 1,2,3, it would generate an error. Here’s an example:
tPos = oZone.getPosition()
if tPos[2] < 45 then ...Above was fixed by making the following change:
tPos = oZone.getPosition()
if tPos.y < 45 then ...See here for further details:
https://stackoverflow.com/questions/61722736/lua-attempt-to-call-a-number-value-near-for-in-error-due-to-unrelated-table-i


This code snippet (which I changed to x, y, z notation) works whereas using 1,2,3 notation caused the error (ie. for, then statement within a for, in loop; not sure if that matters):
function tc.spawnBanners() -- Spawn player banners based on hand-zone position, rotation & scale
local nOffset = 0.75 -- Offset from hand zone position
for gZone, vColor in pairs(tc.handGUIDs_Color()) do
local oHandZone = Util.get(gZone)
local tPos = oHandZone.getPosition()
local tRot = oHandZone.getRotation()
local tSca = oHandZone.getScale()
if (tRot.y < 45) or (tRot.y > 320) or (tRot.y > 135 and tRot.y < 225) then
if tPos.z > 0 then -- Top or bottom
tPos.z = tPos.z - nOffset -- Top (z-axis)
tRot.y = tRot.y - 180
else
tPos.z = tPos.z + nOffset -- Bottom (z-axis)
tRot.y = tRot.y + 180
end
else
if tPos.x < 0 then -- Left or right
tPos.x = tPos.x + nOffset -- Left (x-axis)
tRot.y = tRot.y + 180
else
tPos.x = tPos.x - nOffset -- Right (x-axis)
tRot.y = tRot.y - 180
end
end
tSca.x = tSca.x / 6
tSca.y = 1.00
tSca.z = tSca.z / 2
Util.spawn({
Type = tBannerData_TC,
Pos = tPos,
Rot = tRot,
Sca = tSca,
Call = function(obj) obj.setColorTint(Util.toColor(vColor)) end
})
end
end
This also applies to color vectors (ex. tColor[4] would error but tColor.a would not). However, the color vector in the example below (fixed with .a notation) was just in a for, then statement so it doesn’t seem related to a for, in loop:
function tc.hideTable(bHideTable, bBroadcast) -- Hide/unhide table if indicated
local tColor = oSurface_TC.getColorTint()
for _, gTablePart in ipairs(tPartGUIDs_TC) do
if gTablePart ~= oSurface_TC.guid then
Util.get(gTablePart).attachInvisibleHider("hide", bHideTable)
end
end
if bHideTable then
tColor.a = 0
oSurface_TC.setColorTint(tColor)
if bBroadcast then broadcastToAll("Table hidden!", {0.2, 0.9, 0.2}) end
if bBroadcast then broadcastToAll("Black (Game Master) can see & unhide table", "Black") end
else
tColor.a = 1
oSurface_TC.setColorTint(tColor)
if bBroadcast then broadcastToAll("Table unhidden!", {0.2, 0.9, 0.2}) end
end
end

