Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Would this work in a ModuleScript?

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

✓ Accepted answer

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.

1 comment

0

Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.