Recently I have been trying to create a player whitelist module which can be used as universal script for all whitelists. However I cant figure out how to make it work.
I would make whitelist a dictionary with there userid and then there rank in numbers 1-4 and in the script you require it check if they are in the dictionary and if they are there rank.
I’m not sure I understand what the rest of your code is supposed to do, but here’s a script to put in the ServerScriptService that will go through all the IDs in the whitelist and if it’s not one of them kick the player
Script in ServerScriptService
--Service
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
--Module
local WhiteListModule = require(ReplicatedStorage.WhiteListModule)
--Function
local function CheckIfWhiteList(Player:Player)
local rankName
for i, rank in WhiteListModule.Ranks do
rankName = i
if rank then
for _, PlayerID in rank do
if PlayerID == Player.UserId then -- Compare the UserID in the WhiteList with that of the player who has just joined
return rankName
end
end
end
end
return false
end
--Action
Players.PlayerAdded:Connect(function(Player)
local IsWhiteList = CheckIfWhiteList(Player)
if IsWhiteList then
print(Player.Name.." is in the whitelist with the rank "..IsWhiteList)
else
Player:Kick(Player.Name.." is not whitelist")
end
end)
In this case, the ModuleScript you gave earlier must be placed in replicated storage.
ModuleScript in ReplicatedStorage
local Whitelist = {}
--Whitelist.Mainframe....
Whitelist.Ranks = {
All = {1060189821},
Owner = {1060189821,},
Admin = {0},
Moderator = {0,}
}
--Whitelist.Locks...
return Whitelist
local whitelist = {1234567890}
local kickreason = "kickreason"
game.Players.PlayerAdded:Connect(function(player)
if not table.find(whitelist, player.UserId) then
player:Kick(kickreason)
end
end)