Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Would this work in a ModuleScript?

Asked by 8 years ago

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

1 answer

Log in to vote
1
Answered by 8 years ago

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.

0
Thanks. ISellCows 2 — 8y
Ad

Answer this question