[HELP NEEDED] Troubles with Scripting a GUI in my RPG Game

Hello Fellow Roblox Devs! :wave:

I hope you all are doing well and your creativity is flowing non-stop! I’ve been neck-deep in developing an RPG game and I’ve reached a roadblock that’s been a thorn in my side for a couple of days now.

I’ve been working on scripting a GUI that will display the player’s inventory. I’m aiming for something that’s easy-to-use and attractive at the same time. My current script has the inventory pop up when the player presses ‘I’, but there’s an odd delay and the items are not showing up correctly.

Here’s a snippet of the script I’m using:

-- Inventory script
local player = game.Players.LocalPlayer
local inventory = player:WaitForChild("Inventory")

local openKey = Enum.KeyCode.I
local UIS = game:GetService("UserInputService")

local inventoryUI = script.Parent

local function openInventory(input)
    if input.KeyCode == openKey then
        inventoryUI.Visible = not inventoryUI.Visible

-- Connect function to key press event

The delay occurs when the player presses ‘I’, it takes a few seconds for the inventory to show up. For the inventory display, I’m using a simple GridLayout and adding UI elements as child objects. I’m not getting any errors in the output, which makes this problem even more vexing. :sweat:

Could someone point out if I’m missing something, or recommend a more efficient way to script this? Any help would be greatly appreciated.

On a side note, I’d also appreciate any suggestions or best practices for GUI design on Roblox. This is one area I’ve always found challenging and any advice would be invaluable.

Thanks a ton in advance! Looking forward to hearing from you, awesome devs.


P.S: I hope this post is in the right category. If not, kindly guide me to the correct one. :+1:


Hi, question - can you please describe what the ‘inventory’ variable is? If you are trying to get the place where all of the player’s tools are stored, you would do ‘Backpack’, not inventory. I think an issue might be the :WaitForChild(), could be an infinite yield

The delay is probably due to the use of a server script instead of a local script or a module script.

as for UI design advice, I recommend learning tools like photoshop or any editing software as the best UI designs are produced there and the best place to learn such matters is definitely YouTube.