Why is my Whitelist scripting allowing people who aren't supposed to join to join?


Explanation

I must get a few things clear.

  • I know there is another way to write if Players:GetNameFromUserIdAsync(plr.Name) == Admin then return false, I have kept it like this for specific reasons.
  • The function works if I don’t have anything inside of the function that checks my tables.
  • I know this script is quite long, I apologies for the massive amount of code but quite a lot of it is redundant coding.

Issue

The issues are the following…

  • The function refuses to follow the script when I attempt to check my table(s) for UserIds or Names.
  • The function returns false every time someone joins.

Execute Script

This is the script that triggers my module script.

--Made By MillerrIAm
--------Variables-------
local ControlUIs = {"ControlUI"} --[Change this to the name of your controls.]--
local Player = game:GetService("Players")
local playerCheck = require(game.ServerScriptService["Scripts|Admins"]["ModuleScript|AdminCheck"])
--------Main Code------
Player.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(character)
		print("Added Connected")
		--[ControlUI Protocol]
		spawn(function()
			print("ControlUI Connected")
			if playerCheck.ControlUIs(plr) then
				for x,Panel in pairs (ControlUIs) do
					wait(0.05)
					plr.PlayerGui[Panel]:Destroy()
					warn("Admin Protocol Completed")	
				end
			end
		end)
		--[Ban Protocol]
			print("Ban Connected")
		spawn(function()
			if playerCheck.Banned(plr) then
				local alertmsg = Instance.new("Hint",game.Workspace)
				alertmsg.Text = plr.Name.." attemped to join the game."
				plr:Kick("You're prohibited from entering this game.")
				wait(0.5)
				alertmsg:Destroy()
			end
		end)
			print("Ban Failed")
		--[Whitelist Protocol]
		spawn(function()
			print("Whitelist Connected")
			if playerCheck.Whitelist(plr) then
				wait(0.05)
				warn("WhiteList Protocol Completed")
				local alertmsg = Instance.new("Hint",game.Workspace)
				alertmsg.Text = plr.Name.." attemped to join the game."
				plr:Kick("The server is locked down for maintance... try to come back later.")
				wait(0.5)
				alertmsg:Destroy()
			end
			warn("WhiteList Protocol Failed")
		end)
	end)
end)

Whitelist Module

This is the module I’m using, everything else that’s attached to this module works perfectly fine… however this function seems to be very flawwed.

--[Made By MillerrIAm]--
--[Some ideas illustrated are inspired by kidzrock4 & TerryMichaelBrunk]--
------------------------------[Variables]------------------------------
local Players = game:GetService("Players")
---------[Settings]--------
local Kick = true --Kicks people if they exploit the controls.
local Alert = true --Alerts the server of who attempted to exploit the controls.
local Whitelist = true --Turn this on if you only want certain people to be able to join your game.
local CreatorAdmin = false --Turn this on if you want the creator to have access to the system.
------[Group Settings]-----
local GroupAdmin = false --Checks the Group to see if the person is at/is higher than the GroupRankRequirement.
local GroupID = 0 --Group ID
local GroupRankRequirement = 255 --Max: 255, Min = 1
---------[Admins]--------
--[I recommend using UserId over the name due to the name changing ability.]--
local Admins = {""}
---------[Bans]--------
--[I recommend using UserId over the name due to the name changing ability.]--
local Bans = {""}
---------[Whitelist]--------
--[I recommend using UserId over the name due to the name changing ability.]--
local WhitelistPersonel = {""}
------------------------------[Main Code]------------------------------
local playerCheck = {}

function playerCheck.Whitelist(plr)
	if Whitelist then
		for _,Personel in pairs (WhitelistPersonel) do
			for x,Admin in pairs (Admins) do
				if CreatorAdmin then
					if Players:GetNameFromUserIdAsync(plr.Name) == 678299 then
						return false
					elseif GroupAdmin then
						if plr:GetRankInGroup(GroupID) >= GroupRankRequirement then
							return false
						elseif Players:GetNameFromUserIdAsync(plr.Name) == Admin then
							return false
						elseif Players:GetUserIdFromNameAsync(plr.UserId) == Admin then
							return false
						elseif Players:GetNameFromUserIdAsync(plr.Name) == Personel then
							return false
						elseif Players:GetUserIdFromNameAsync(plr.UserId) == Personel then
							return false
						else
							return true
						end
					elseif Players:GetNameFromUserIdAsync(plr.Name) == Admin then
						return false
					elseif Players:GetUserIdFromNameAsync(plr.UserId) == Admin then
						return false
					elseif Players:GetNameFromUserIdAsync(plr.Name) == Personel then
						return false
					elseif Players:GetUserIdFromNameAsync(plr.UserId) == Personel then
						return false
					else
						return true
					end
				elseif GroupAdmin then
					if plr:GetRankInGroup(GroupID) >= GroupRankRequirement then
						return false
					elseif Players:GetNameFromUserIdAsync(plr.Name) == Admin then
						return false
					elseif Players:GetUserIdFromNameAsync(plr.UserId) == Admin then
						return false
					elseif Players:GetNameFromUserIdAsync(plr.Name) == Personel then
						return false
					elseif Players:GetUserIdFromNameAsync(plr.UserId) == Personel then
						return false
					else
						return true
					end
				elseif Players:GetNameFromUserIdAsync(plr.Name) == Admin then
					return false
				elseif Players:GetUserIdFromNameAsync(plr.UserId) == Admin then
					return false
				elseif Players:GetNameFromUserIdAsync(plr.Name) == Personel then
					return false
				elseif Players:GetUserIdFromNameAsync(plr.UserId) == Personel then
					return false
				else
					return true
				end
			end
		end	
	end
end

return playerCheck

Thank you for taking the time to read and if you can help, please do.

1 Like

I think you’ve got it the other way around. GetNameFromUserIdAsync requires the parameter to be an int64 value; which is the player’s ID. GetUserIdFromNameAsync requires the parameter to be a string, which is the player’s name.

It says it in there, FromUserId, FromName.

It should be
Players:GetNameFromUserIdAsync(plr.UserId) == Admin
Players:GetUserIdFromNameAsync(plr.Name) == Admin
instead.

2 Likes