This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
magnum_pu's profile picture

Attempt To Index (a nil value) help

Started by magnum_pu, 12 January 2014 - 03:24 PM
magnum_pu #1
Posted 12 January 2014 - 04:24 PM
Hello, I'm very new to Lua and this is my first time trying to use monitors. I'm trying to print simple text onto a monitor on the server I own (hosted by Akliz if that info is necessary), and I get an error: "startup:3: attempt to index (a nil value). But I don't get this problem on single player, my text prints fine with the same code there.

my code:

monitor = peripheral.wrap("right")

m.setTextScale(1)
m.write("Test")

Why am I getting this error, how can I fix it, and why is this only happening over multiplayer?

Thanks!
Lyqyd #2
Posted 12 January 2014 - 06:05 PM
You wrap the monitor into the variable "monitor", then try to use it with the variable "m". You should pick one or the other and use it consistently.
TheOddByte #3
Posted 13 January 2014 - 12:33 PM
As Lyqyd said, You're wrapping the monitor into the variable 'monitor' but you use it like you've wrapped it as 'm'
One way to fix it below, Or change all the m:s to monitor below.

local m = peripheral.wrap("right")

m.setTextScale( 1 )
m.write("Hello World!")
Hope this helped