As a Roblox developer, it is currently too hard to determine and alter the shown/hidden state of leaderstats. Currently our main method through scripting to show/hide leaderstats is to use StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true/false)
.
And StarterGui:GetCoreGuiEnabled(Enum.CoreGuiType.PlayerList)
will only get this value.
Consider the following operations:
1. StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
2. StarterGui:GetCoreGuiEnabled(Enum.CoreGuiType.PlayerList) -- returns true
3. player press tab to hide the leaderstats
4. StarterGui:GetCoreGuiEnabled(Enum.CoreGuiType.PlayerList) -- still returns true
5. StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
6. StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true) -- this also show the leaderstats
So apparently, besides the ‘Enabled’ property, there is a hidden ‘Visible’ property for leaderstats. However the Visible property is also affected by setting ‘Enabled’
-- current apparent behaviour
PlayerList.Enabled = true -- initial states usually
PlayerList.Visible = true
-- on press tab
PlayerList.Visible = false
print(StarterGui:GetCoreGuiEnabled(Enum.CoreGuiType.PlayerList)) -- returns true because PlayerList.Enabled is still true
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
-- equivalent to:
-- PlayerList.Enabled = false
-- PlayerList.Visible = false
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
-- equivalent to:
-- PlayerList.Enabled = true
-- PlayerList.Visible = true
-- side effect: it is made visible, although player had it hidden
If Roblox is able to address this issue, it would improve my development experience because duration cutscenes, it is advised to hide the leaderstats like so:
https://create.roblox.com/docs/players/leaderboards#hide-the-leaderboard
after the cutscene, we would want to restore the leaderstats state to before, including the Visible state