So i made a script which supposed to hide all my custom made GUI if i press H.
local Keyboard = game:GetService("UserInputService")
Keyboard.InputEnded:connect(function(inputObject, gameProcessedEvent)
if gameProcessedEvent then return end
local AlreadyHidden = false
local ListGUI = game.Players.LocalPlayer.PlayerGui.CustomGui:GetChildren() -- CustomGui in here is Folder
if inputObject.KeyCode == Enum.KeyCode.H then -- If the key H is pressed
print ("Key H is pressed")
if AlreadyHidden == false then
for i,GUI in pairs(ListGUI) do
GUI.Enabled = false
end
AlreadyHidden = true
print("GUI hid")
print(AlreadyHidden)
else
for i,GUI in pairs(ListGUI) do
GUI.Enabled = true
end
AlreadyHidden = false
print("GUI shown")
end
end
end)
It work if i press H to hide the GUI. However, it’ll never work if i press H to show the custom GUI. No error happen here. Any idea?
Extra Info : The script itself is located in StarterPlayerScripts and is Local script. and the CustomGui is located in StarterGui