RobloxLsp
RobloxLsp copied to clipboard
"Workspace" & "Game" are treated as an undefined global
Meanwhile it's another way to reference the "workspace" & "game".
print(Workspace==workspace, Game==game) --> true, true
Workspace isn't a global it's a service so this error is correct, workspace is just a shortcut for accessing it without having to game:GetService("Workspace")
:
do -- service access
local Workspace = game:GetService("Workspace")
print(Workspace) -- no error
end
do -- shortcut global access
print(workspace)
end
-- these two examples are the same, the first is just longer
Workspace isn't a global it's a service so this error is correct, workspace is just a shortcut for accessing it without having to
game:GetService("Workspace")
:
print(workspace)
print(game.Workspace)
print(Workspace) -- This should be treated the same as workspace in terms of highlighting, IMO.
print(game:GetService("Workspace"))
Workspace isn't a global it's a service so this error is correct, workspace is just a shortcut for accessing it without having to
game:GetService("Workspace")
:print(workspace) print(game.Workspace) print(Workspace) -- This should be treated the same as workspace in terms of highlighting, IMO. print(game:GetService("Workspace"))
I think Workspace should be treated as it is now, because it is just a service, the documentation I linked earlier affirms this.
All workspace
does is give you a shortcut to it, which admittedly to me, on Roblox's part, is pretty confusing.
Workspace isn't a global and it isn't workspace so highlighting it as such would be deceptive wouldn't you agree? In my opinion the syntax highlighting should highlight strictly what something really is, as it does now.
They are just pre-defined globals, whereas Workspace isn't a global, you have to define it or access it through other globals, making it a non-global.
For clarity on how I see this, this is all the same as saying RunService or Debris are treated as undefined globals.
Meanwhile it's another way to reference the "workspace".
Keep in mind that this is the other way around, workspace
is another way to reference Workspace
.
Workspace isn't a global it's a service so this error is correct, workspace is just a shortcut for accessing it without having to
game:GetService("Workspace")
:print(workspace) print(game.Workspace) print(Workspace) -- This should be treated the same as workspace in terms of highlighting, IMO. print(game:GetService("Workspace"))
I think Workspace should be treated as it is now, because it is just a service, the documentation I linked earlier affirms this. All
workspace
does is give you a shortcut to it, which admittedly to me, on Roblox's part, is pretty confusing.Workspace isn't a global and it isn't workspace so highlighting it as such would be deceptive wouldn't you agree? In my opinion the syntax highlighting should highlight strictly what something really is, as it does now.
They are just pre-defined globals, whereas Workspace isn't a global, you have to define it or access it through other globals, making it a non-global.
For clarity on how I see this, this is all the same as saying RunService or Debris are treated as undefined globals.
Meanwhile it's another way to reference the "workspace".
Keep in mind that this is the other way around,
workspace
is another way to referenceWorkspace
.
Did you run my code example? Then, can you explain why the third line references Workspace instance just like the other lines? And no, you don't need to pre-define it 😌
For clarity on how I see this, this is all the same as saying RunService or Debris are treated as undefined globals.
RunService and what-not will print it nil when accessed as-is. Workspace
is special in this as it points to the Workspace instance. This only shows that you didn't run the code before replying 👀
Ah, I didn't run the code as I was on my phone, I genuinely believed it was service only and chose to reply anyway, forgot there was a global since it's been deprecated forever so I've never used it, sorry should've checked.
I retract what I said then, I apologize for my baseless argument, I'll fact check myself more, thank you for pointing out.
Adding onto this
Game
is affected too
print(Workspace==workspace, Game==game) --> true, true