In short, File
refers to a file uploaded to Studio by a plugin/command bar.
No, this is not the same thing.
This is likely an unimplemented keyword, or an accidentally implemented keyword on Roblox’s part. This is not a part of regular Lua.
The compiler is just treating it as an undefined variable, and since variables are initialized as nil
, that’s why it’s printing nil.
I believe its a left over from Roblox CLI or smth since that can probably fetch the directory it was started under.
Roblox CLI, for the uninitiated, is a command-based version of Roblox Studio for running internal tests. Its an internal tool sadly.
It might behave similarly to how self behaves. It means nothing outside of a scenario where it is actually used.
Not necessarily, self is simply an argument that is passed when you call a table method with a :
, simply calling PromptImportFile doesn’t suddenly set a File global, otherwise it would’ve happened above.
Hmm interesting, it appears to be an empty length table according to Luau’s linter.
Here’s a fixed length dictionary for comparison
There might be a situation where File isn’t nil is what I’m trying to say. So far the API isn’t very helpful.
afaik, none of the built-in API methods inject globals into a scope, so this is would be quite unusual for Roblox.
This is my best guess: All data types are syntactically highlighted. File is also a data type even though it does not show it as one on the API. So my guess is even though File is nothing for some reason it still gets syntactically highlighted since it is a data type.
maybe file is like robloxs input output class. Try doing like
local file = File.open("example.lua", "w+")
File.output(file)
File.write("[[
test
test
]]")
File.input(file)
print(File.read())
File.close(file)
The File global is likely a Lua global that was stripped away as Roblox doesn’t want us accessing the file class.
That thing you are referencing is lowercase file, plus why would they remove it and still keep it syntactically highlighted if it is nothing.
Nearly every (global) function has a lowercase letter in Lua, yet Roblox has uppercase ones. Also, most Roblox functions were lowercase, but are now deprecated in favor of uppercase ones.
Most likely for CoreScript usage.
UnvalidatedAssetService: It is a service that can’t be used by developers, yet is syntactically highlighted.
file
as lowercase does not get syntactically highlighted. File
as uppercase does get syntactically highlighted. Also UnvalidatedAssetService
does not get syntactically highlighted.
Pretty sure they removed access to File. I think the Local File Importer (Plugin: Local File Importer (Import Images from your Computer!) - #19 by XAXA) plugin used it. That plugin has been broke for a long time last time I checked. Here’s the reference in the post I linked: File - Roblox API Reference.
It does if you put it within GetService()