SebyGHG
SebyGHG

Reputation: 13

Lua Script error: bad argument #2 'to open' (invalid mode)

I am trying to create a file or read a already existing file but I keep getting the same error: bad argument #2 'to open' (invalid mode)

player_pos = player.pposition()
world_nam = server.worldName()
attribs = player.attributes()
xp = attribs.id(6).value
timesavename = world_nam .. player_pos .. xp
f = io.open(timesavename, ".txt", "r")
if f ~= nil then
    io.input(f)
    resultstart = f:read("*line")
    resultstop = f:read("*line")
    f:close()
end

Upvotes: 0

Views: 592

Answers (1)

Whoman
Whoman

Reputation: 42

Using , in a function will make it think its another argument, like in the comment you got you should concat the strings with ..

Upvotes: 2

Related Questions