So basically I am making a 2D game. When the game starts I want the player list to automatically hide, but the player can still press tab to show it if they want.
I have starter gui defined in a variable called “StarterGui.” Please help me make the script?
Well I don’t believe there is any api that makes it hidden when called without disabling it. The only other thing I can think of is to make a custom player list by disabling the default one entirely and making the custom one work the way you want it.
Disable it by default, or keep it enabled. When it needs to be disabled, disable it. When the player presses TAB, toggle it with SetCoreGuiEnabled & GetCoreGuiEnabled.
Building on from pos0’s reply, it’d look something like this
local StarterGui = game:GetService('StarterGui')
local UIS = game:GetService('UserInputService')
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false) -- hides the leaderboard by default
UIS.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.Keyboard then
if Input.KeyCode == Enum.KeyCode.Tab then -- checks if tab button was pressed
local Status = StarterGui:GetCoreGuiEnabled(Enum.CoreGuiType.PlayerList) -- gets the current status of the leaderboard
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, not Status) -- hides or shows it depending on status
end
end
end)