Hey was wondering if that is possible, I did this for example;
Controller:
local banned = game.ServerScriptService.BannedPlayers
game.Players.PlayerAdded:connect(function(p)
if banned[p.Name] then
p:Kick("You are banned from this game")
end
end)
Making a ban module/script is possible, it has been possible for a very long time.
However, if you’re banning a user from the game. You should use their UserIds, not names. As they can easily change their name and regain access to your game. Which is not at all ideal for a ban system.
Also going to point out in the controller section. If you don’t call require on the module it won’t work, and on the PlayerAdded event, you should be using :Connect not :connect, given the fact the latter is deprecated and should not be used anymore.
Obtaining a UserId from a module is as easy as what you’re doing to obtain the names from the module. You need to replace the string(s) in the dictionary with the Player’s UserId.
Then make the appropriate adjustments in the PlayerAdded event.
As stated by Quenty and Nuclear_Energy it is better to use a Datastore then it is to use a dictionary to log banned players. This way you can create a ban command, and that way it updates across all servers. Without needing to shut-down all instances just to ban someone.