Can someone tell me if this would work in a ModuleScript
, and if not what am I doing wrong with it that won't allow it to work in a ModuleScript
?
local players = game:GetService("Players") local module = {} function module:Test() for _,v in pairs(players:GetPlayers()) do print(v.Name) end end return module
You should test it before posting a question here :/ Yes it will work. ModuleScripts inherit the environment that they were required from (if you require it from a localscript it will act like a localscript and if you require it from a script it'll behave like a script), but that isn't a concern here because game.Players and players:GetPlayers() are usable from both the server and client.