How do I make a player whitelist script?

Hello, I am Exit. I am a newer scripter looking for help.
Here is my question:

  • How do I make a player whitelist script. What I mean is how do I make it so if it’s not an assigned player, they get kicked. I know they have the play testers option, but this is something I’d like to know anyway.
4 Likes

The best way (if you don’t have a group) would to keep track of every play tester’s User ID. Then when a player joins check if any joining player’s User ID is contained inside the whitelistUserIDs table.

local whitelistUserIDs = {}

game.Players.PlayedAdded:Connect(function(player)
    if not table.find(whitelistUserIDs,player.UserId) then --If the UserID value is not in the table this returns nil. In Lua nil equals false.
        player:Kick("You are not whitelisted on this server.")
    end
end)
16 Likes

You would want to keep track of the players that are whitelisted

local Whitelist = {--Insert whitelisted user ids } 

After that you want to check if the player who joins is part of the Whitelist. If they are not part of the Whitelist then you can player:kick() them

4 Likes

Depends on how smart you wanna do it, you could use another site which uses HTTPS read services to read if a userid is whitelisted, would you like an example or do you know what I mean?

1 Like

Yes, that would be nice if you could provide an example

Basically just use a Pastebin link or some sort of paste website to store your UserId’s or however you want to identify users, then you can send a HTTP request with HttpService:RequestAsync() and use the GET method and the Url should be the raw version of the paste. You can format the paste into JSON and decode it with HttpService:JSONDecode() when you send the request to the raw paste which will return a table of every whitelisted userid, etc.

4 Likes