I knew I should check the code... even though I didn't see any errors at first glance.
1) firstvis=0; how does this variable behave outside of functions? (Does it definitely not need to be assigned anything? Is it global or something else?)
2) Did we write xt, yt, zt == x, y, z correctly? Without declaring the data type.
3) The script editor gives an error in the line below.
elseif firstvis>=1 and xt,yt,zt == x,y,z then
*I'm not familiar with the Lua language, but I tried the following:
*Specifying the data type... number or something else... the error didn't disappear.
*Deleting the condition (firstvis>=1 and xt,yt,zt == x,y,z) then it stopped complaining.
*Putting the entire condition in parentheses also didn't help.
As I understand it, this syntax doesn't work in Lua.
Try:
elseif firstvis>=1 and xt == x and yt == y and zt == z then
as a last resort:
elseif firstvis>=1 and {xt,yt,zt} =={x,y,z} then
but, in theory, the first one should definitely work