Inventory GUI will not open

Hello, my name is Light

Yesterday I was working on a inventory script but for some reason couldn’t get it to open even though everything seems right. the only thing I could think that could be wrong is me trying to set it to visible instead of doing some other way but this is the only way I could imagine it.

If anybody with expierance with these types of scripts could tell me what I did wrong I would highly appreciate!

Btw this script is located in StarterPlayerScripts

game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.Tab then
		game.StarterGui.ScreenGui.Inventory.Visible = true
	end
end)

Any help is appreciated, thank you!

1 Like

I belive you may be missing some parts of the code: Here is the developer hub form for UIS (Scroll all the way to the bottom for an example.)
Looking at the form, and from personal experience, most of the UIS Keycodes I’ve seen are a little bit longer :wink:

The problem is that they make GUI visible in StarterGui not PlayerGui.

PlayerGUI? Ive never heard of this, how do I put a gui into that?

Read through this, it talks about how to access it and so and so

1 Like

This is where GUIs are located in Player.

hmmm I will look into this, this is my first time trying to make a GUI so I had no idea that playerGui was a thing

Yeah, Player GUI is specific to players and Starter Guis are available to everyone. So, with StarterGui, when one person pressed tab, everyones inventory would open in a Server Script

Thank you for the help, the script now works

local invVisible = game.Players.LocalPlayer.PlayerGui.ScreenGui.Inventory.Visible
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
	if input.KeyCode == Enum.KeyCode.Tab then
		if invVisible == false then
			invVisible = true
		else invVisible = false
		end
	end
end)