--ServerScript.
local Admins = {"Vezious"} local ServerOnlyBans = false -- Allow admins to ban people not in the server with their UserId? local ReloadTime = 300 -- 5 Minutes, Change to how many seconds it should wait between updating Bans Table KickMessage = ("This game has shut down.") -- Default Message, You may change this. require(script.Parent.ModuleScript)
So, what i'm trying to achieve here is to get the variables from the ServerScript and let the Module script use them. Any ideas?
--Module
script = nil local module = {} local Event = game.ReplicatedStorage:FindFirstChild("Bans") or Instance.new("RemoteEvent",game.ReplicatedStorage) Event.Name = "Bans" local BansTable = nil function LookForIdPlayer(UserId) end function LookForStringPlayer(StringName) end function RefreshTable() end function CheckAdmin(PlayerName,PlayerID) end function Unban(UserId) end function Ban(UserId) end function CheckStatus(UserId) end game.Players.PlayerAdded:connect(function(Player) if (CheckStatus(Player)) == true and DisableKickOnJoin == false then Player:Kick(KickMessage) end if Player.UserId == game.CreatorId or CheckStatus(Player.Name,Player.UserId) then print(Player.Name.." Has Joined And Has Admin Access") Player.Chatted:connect(function(Msg) end) while true do end return module
The cleanest way to make this work is to pass the parameters to the module. The module can return a function that takes these in:
-- SERVER SCRIPT local SetupAdmin = require(themodule) SetupAdmin(Admins, false, 300, "This game has shut down")
-- MODULE SCRIPT return function(Admins, ServerOnlyBans, ReloadTime, KickMessage) local function CheckAdmin(name) ...... end ...... end
Since that's starting to be a lot of parameters, it probably makes sense to send a table over instead (so that you don't mess up the order / miss one, etc):
-- SERVER SCRIPT local SetupAdmin = require(themodule) SetupAdmin { Admins = {"Vezious"}, ServerOnlyBans = false, ReloadTime = 300, KickMessage = "This game has shut down" }
-- MODULE SCRIPT return function(settings) local Admins = settings.Admins local ServerOnlyBans = settings.ServerOnlyBans -- etc.... local function isAdmin(name) -- ..... end -- ...... end
There are a few ways to attempt to get around this, global variables (not recommended) or storing a value outside the script as a physical value such as a BoolValue or a NumberValue. If you where directly sending a variable to the module from another script, that would be easy as functions in modules act just like regular functions but you are trying to fetch a value from a regular script with a module and that won't quite work, it's not a two way door. But if you turned the other script into a module script, you would have no problem (I think).