Whitelist script not working

I’m trying to make a whitelist GUI via UserID for people to use, but it doesn’t seem to work if everything’s set.

When I tried to set the UserID to something different, I still had the prompt to open the GUI (which shouldn’t happen.) I also wanted to try something new and work with tables a little bit, so I don’t know if that’s part of the problem or not.

(All in a LocalScript btw)

gamePlayerList = game:GetService("Players")
intAdmin = game.ReplicatedStorage:WaitForChild("InteractionAdmin").InteractionHandler

local AllowedUsers = { -- List of users that can access the gui. Remember to put a comma after every ID
	331186903 --Change this to be your own
}

gamePlayerList.PlayerAdded:Connect(function(plr) --Whitelist
	task.wait()
	if table.find(AllowedUsers,plr.UserId) then return end
	if not table.find(AllowedUsers,plr.UserId) then game.Players.LocalPlayer.PlayerGui.InteractionDisablerAdmin:Destroy() end

Bonus points if anyone can figure this out too because it’s not working either

gamePlayerList.PlayerAdded:Connect(function(plr) --Add to list
	script.Parent.Storage.Player.PlayerName.Text = plr.Name
	task.wait()
	script.Parent.Storage.Player:Clone().Parent = script.Parent.Panel.PlayerList.List
end)
local gamePlayerList = game:GetService("Players")
local intAdmin = game.ReplicatedStorage:WaitForChild("InteractionAdmin").InteractionHandler

local AllowedUsers = { -- List of users that can access the gui. Remember to put a comma after every ID
	331186903 ; --Change this to be your own
	0;
	0;
}

local LocalPlayer = game.Players.LocalPlayer
local PlayerGui = LocalPlayer.PlayerGui

if table.find(AllowedUsers,LocalPlayer.UserId) then
	warn("Allowed")	
	return
else
	warn("No allowed-user found ")	
	PlayerGui.InteractionDisablerAdmin:Destroy()
end
1 Like

Although the solution has been given (and they fail to explain what they did differently), I think there are some things that could be improved upon.

This could be more readable.

local WhiteListedUsers = { 331186903, 1269880 }



local PlayersService = game:GetService("Players") -- Renamed the variables to be clearer about what they are.
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local AdminRemoteFolder = ReplicatedStorage:WaitForChild("InteractionAdmin")
local AdminInputRemote = AdminRemoteFolder:WaitForChild("InteractionHandler")
local StorageFolder = script.Parent:WaitForChild("Storage")
local ListStorage = script.Parent:WaitForChild("PlayerList")
local AdminGui = object_StorageFolder.Player
local PlayerList = ListStorage.List


PlayersService.PlayerAdded:Connect(function(plr)
	plr:WaitForChild("PlayerGui") -- Let's wait for the PlayerGui to load
	if table.find(WhiteListedUsers, plr.UserId) ~= nil then -- Is the player whitelisted?
		local NewAdminGui = AdminGui:Clone() -- Let's clone and make the changes from there
		NewAdminGui.PlayerName.Text = plr.Name
		NewAdminGui.Parent = PlayerList
		-- local NewInteractionDisabler = <path>.InteractionDisablerAdmin:Clone()
		-- NewInteractionDisabler.Parent = plr.PlayerGui
	elseif plr.PlayerGui:WaitForChild("InteractionDisablerAdmin", 3) ~= nil then -- Is the player not in the list and has the interaction disabler? Let's also timeout WFC after 3 seconds just in case.
		plr.PlayerGui.InteractionDisablerAdmin:Destroy() -- Destroy it.
	end
end)

This would entirely be handled server-side rather than client-side. This would decide whether to add them to the list and no exploiter could potentially manipulate keeping the interaction disabler.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.