file.Exists not working?

Hello, currently im attempting to make an anti cheat using file.Exists and debug.getinfo, but for some reason file.Exists doesn’t work.

Right now here is my code:

Server:



util.AddNetworkString("verifylua");
net.Receive("verifylua", function(size, ply)
	local file = net.ReadString();
	if (!file.Exists(file, "GAME")) then
		print("UNAUTHED FILE: "..file)
	else
		print("AUTHED FILE: "..file)
	end
end)


Client:



for k, v in pairs(hook.GetTable()["HUDPaint"]) do
	local info = debug.getinfo(v)
	net.Start("verifylua");
		net.WriteString(info.short_src);
	net.SendToServer();
end


And this is the error I get:


177: attempt to index a string value with bad key ('Exists' is not part of the string library)

Line 177 is:


if (!file.Exists(file, "GAME")) then

How come file.Exists isn’t working?

Thanks for any help in advanced.

When you do this:
[lua]local file = net.ReadString()[/lua]
you block yourself from accessing the file library, because when lua sees the name “file” it looks for the local first, and it finds it, so it never reaches the global file library.

The fix is simple: don’t use library names as variable names.

[lua]util.AddNetworkString(“verifylua”);
net.Receive(“verifylua”, function(size, ply)
local myfile = net.ReadString();
if (!file.Exists(myfile, “GAME”)) then
print("UNAUTHED FILE: "…myfile)
else
print("AUTHED FILE: "…myfile)
end
end)[/lua]

(or a more descriptive name)