I have such a problem. I made a script so that it hides the GUI of the player who pressed the P key. I created two conditions. 1 condition - if the player presses P and if the GUI is visible (by default it is visible) then the GUI disappears. 2 condition - if the GUI is false and the P key is pressed, then the GUI reappears. When entering the game, the hood disappears when you press P, but when you press P again, it remains. When pressing the WASD keys, condition 1 repeats, condition 2 does not take effect. How can I fix this?
**local gui = game.Players.LocalPlayer.PlayerGui
local UIS = game:GetService("UserInputService")
local startergui = game:GetService("StarterGui")
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.P then
gui.Compass.Enabled = false
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
print("1")
end
end
end)
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.T then
if gui.Compass.Enabled == false and input == nil then
if startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false) then
gui.Compass.Enabled = true
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
print("2")
end
end
end
end
end)**