1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
dir = "/sys/lua/data/" defclr = 012255012 on = {} USGN = {} ranking = {} saycolor = {} function loaduser(id) 	local file = io.open (dir..USGN[id]..".txt") 	if file then 		local ranking_f,saycolor_f = file:read ("*n","*n") 		ranking[id] = ranking_f or 1 		saycolor[id] = saycolor_f or 255255000 		file:close() 	else 		ranking[id] = 1 		saycolor[id] = 255255000 		local ranking_f = ranking[id] 		local saycolor_f = saycolor[id] 		file:write(ranking_f.."\n"..saycolor_f) 		file:close() 	end end function welcomemsg(id, md) 	if md == 1 then 		msg2 (id, "\169"..defclr.."Welcome to"..game("sv_name")"!") 	end end function saveuser(id) 	local file = io.open (dir..USGN[id]..".txt") 	local ranking_f = ranking[id] 	local saycolor_f = saycolor[id] 	file:write(ranking_f.."\n"..saycolor_f) 	file:close() end	 addhook("join", "on.join") function on.join(id) 	USGN[id] = player(id, "usgn") 	if USGN[id] > 0 then 		loaduser(id) 	else 		welcomemsg(id, 1) 	end end addhook("leave", "on.leave") function on.leave(id) 	if USGN[id] > 0 then 		saveuser(id) 	end end
I attempted to create a file using users' USGN id as file name.
But it returns me
1
LUA ERROR: sys/lua/autorun/new 1.lua:20: attempt to index local 'file' (a nil value)
I wrote this file according to Rainoth.