#inventory closing not working properly

4 messages · Page 1 of 1 (latest)

marsh quest
#

this is the improved script that doesnt work at all:

local UserInputService = game:GetService("UserInputService")
local inventoryGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("ItemInvGui") -- Reference to the inventory GUI
local armorGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("ArmorInvGui") -- Reference to the armor inventory GUI

local eKeyCode = Enum.KeyCode.E

local currentGui = nil -- Variable to store the currently visible inventory GUI

UserInputService.InputBegan:Connect(function(input, isProcessed)
    if input.KeyCode == eKeyCode and not isProcessed then
        if currentGui then
            currentGui.Enabled = false -- Close the currently visible inventory GUI
            currentGui = nil -- Reset the currentGui variable
            game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
        else
            if inventoryGui.Enabled then
                currentGui = inventoryGui -- Set the currentGui variable to the inventory GUI
            elseif armorGui.Enabled then
                currentGui = armorGui -- Set the currentGui variable to the armor inventory GUI
            end
            if currentGui then
                currentGui.Enabled = false -- Close the currentGui inventory GUI
                currentGui = nil -- Reset the currentGui variable
                game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
            end
        end
    end
end)```


there is a image attached too. those are the 4 sections' names
Ping me if you know an answer. Thanks alot!
light stratus
#

Send a video of of you testing the your inventory system and a screenshot of the output if there is/are error(s) printed in the output.

marsh quest