It’s nothing just ignore it. It’s a roblox script editor that doesn’t like modules for a reason. It wont break your code you can just leave it the way it is it wont give any errors in console so its fine.
While that gets rid of the orange underline, it’s not what I want. The underline appears if I use GetService, and I’m not sure if it’s a bug or a fault of my own.
I have created a variable. It’s just something that’s bothering me, the fact that there’s an ugly orange line in my script when there’s nothing wrong, and the fact that it only appears when doing
local ServerStorage = game:GetService("ServerStorage")
No, it doesn’t. GetService() is better because it gets the corresponding service even if you change the service’s name, not because it creates a new service or is more efficient. For example, if you change the name of the ReplicatedStorage to ClientStorage, doing game.ReplicatedStorage will error but doing game:GetService("ReplicatedStorage") will return the correct renamed service.
It identifies a server despite a name change because by default the ClassName and Name for services like ReplicatedStorage are the same*, which leads to the behaviour @VegetationBush identified.
* some exemptions apply but these are legacy problems for unused services (i.e LuaWebService)
Just for clarification because this can be misunderstood, it does try to create initialize a service that doesn’t exist. That’s almost never why it is used, but it is a reason why it can be a good practice.
It’s in a server-script, and the problem is the typechecking, it does not error and functions correctly.
At this point I’m rather sure it’s some sort of type checking bug. Hopefully someone with permissions to post in #bug-reports or use the bug report wizard sees this and reports it to Roblox.
This typechecking bug appears to have been fixed, I’m not sure what caused it, but, if you encounter one similar to this, make a new thread/post about it.
The specific scenario I had it in was fixed and is still fixed as far as I can tell:
local ServerStorage = game:GetService("ServerStorage")
-- There USED to be a "Unknown require: unsupported part" warning here
local MyModule = require(ServerStorage.MyModule)
The warning still occurs when dynamically requiring modules, but that’s a separate problem and not nearly as annoying as the bug originally reported:
local MyModules = ModuleScripts:GetChildren()
local Modules = {}
for _, ModuleScript:ModuleScript in MyModules do
-- The "Unknown require" warning occurs here RIGHT NOW.
-- This is because Luau can't know what the ModuleScript is without looking
-- at the MyModules Folder, which it doesn't have access to.
Modules[ModuleScript.Name] = require(ModuleScript)
end