How to hide the PlayerList without Disabling It?

image

Currently, to hide the PlayerList I use this:

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)

The problem is that this no longer allows the PlayerList to be shown again (when the player presses TAB).
How is it possible to hide the PlayerList by default in the game but still allow the player to show it whenever they want by pressing TAB?

Hold to toggle?

local Game = game
local UserInputService = Game:GetService("UserInputService")
local StarterGui = Game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled("PlayerList", false)

local function OnInputBegan(InputObject, GameProcessed)
	if GameProcessed then return end
	if InputObject.KeyCode.Name == "Tab" then
		StarterGui:SetCoreGuiEnabled("PlayerList", true)
	end
end

local function OnInputEnded(InputObject, GameProcessed)
	if GameProcessed then return end
	if InputObject.KeyCode.Name == "Tab" then
		StarterGui:SetCoreGuiEnabled("PlayerList", false)
	end
end

UserInputService.InputBegan:Connect(OnInputBegan)
UserInputService.InputEnded:Connect(OnInputEnded)

Or press to toggle?

local Game = game
local UserInputService = Game:GetService("UserInputService")
local StarterGui = Game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled("PlayerList", false)

local function OnInputBegan(InputObject, GameProcessed)
	if GameProcessed then return end
	if InputObject.KeyCode.Name == "Tab" then
		StarterGui:SetCoreGuiEnabled("PlayerList", not StarterGui:GetCoreGuiEnabled("PlayerList"))
	end
end

UserInputService.InputBegan:Connect(OnInputBegan)
1 Like

You have fewer badges than you deserve…

1 Like