Jump to content




file.write not working


3 replies to this topic

#1 The Penguin21

  • Members
  • 19 posts
  • LocationC:\Windows\System32\

Posted 06 September 2017 - 01:54 PM

Ok so I was trying to create a remote control program, but it ain't working.
So first i typed in
 local file fs.open("tempfile", "w") 
and after that
 file.write("message") 
but it outputs an error:
 attempt to index ? (a nil value) 


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 06 September 2017 - 02:00 PM

If you're doing this in the lua prompt, that's because the scope of each new line is different. So your file variable doesn't exist after you press "enter".

#3 The Penguin21

  • Members
  • 19 posts
  • LocationC:\Windows\System32\

Posted 06 September 2017 - 02:07 PM

local file fs.open("tempfile", "w")
file.write("message")
file.close()
This is the code i got so far, its in a file, but it wont seem to work neither

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 06 September 2017 - 02:11 PM

You've forgotten to use the assignment operator.
local file = fs.open( "tempfile", "w" )







1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users