Scripting Inventory GUI SOLVED

So I’m trying to script again, this time just trying to make a simple Inventory Gui. Basically I want it so that when you click the inventory button, it makes an inventory GUI wich will contain items you collect appear below the button. Like I said in my last post I’m not very good at scripting and ma most likely doing something wrong. Here is what I have so far, although an error is popping up and I’m not sure how to fix it or where to go from here.

local button = script.Parent
local toggled = false
local GUI test = GUI test
local invenimage = GUI test.Parent

local function onButtonActivated()
if toggled == true then
invenimage = visible

end

end

button.Activated:Connect(onButtonActivated)

Any help would be appreciated, thanks!

1 Like

You can’t call “Visible” directly, it’s a properties of the object, so you call it like any other edit :
invenimage.Visible = true/false

Also, i’m not sure what you’re trying to do here, but to make a path, you’ll have to add a dot for Descending or “.Parent” to Ascend in the explorer via the script. btw the variable cannot have a space so you’d do this

local GUI_Test =

Oh ok, thanks. Also I must have missed that, I think I was tryong to fix issues and accidently ended up putting “GUI test = GUI test” (Don’t question how I did that on accident.)

local button = script.Parent
local toggled = false
local GUI_test =
local invenimage = Inventory_Image.GUI_test.Parent

local function onButtonActivated()
if toggled == true then
invenimage.Visible = true

end

end

button.Activated:Connect(onButtonActivated)

Ok so this is what I’ve changed it to, I’m not sure what to put after GUI_test to make it all work.

If you want to make your gui open, just do this

local button = script.Parent.ToggleButton
local frame = script.Parent.Frame

button.MouseButton1Click:Connect(function()

if frame.Visible == true then

frame.Visible = false

else

frame.Visible = true

end

end)

You can put your code in a code block to make it easier to read

if code then print("here") end

You do that like this:
image

Also I think you would put this for Gui_test:

local GUI_test = Inventory_Image.GUI_test

Oh ok, I thought it automatically did that and was confused why it wasn’t doing it for the script I posted.
@xRuinedSeven That didn’t seem to work, I assume I’m supposed to chang something in the script to make it fit my situation? If so what do I change?

Change “button” to the name of the button the player clicks to open the inventory gui

Change “frame” to the name of the frame that shows them their inventory

Honestly, you may want to start with something more basic, this isn’t really the best situation for starters.

if frame.Visible == true then
frame.Visible = false
else
frame.Visible = true
end

Can be written like this to help you keep your code less cluttered

frame.Visible = not frame.Visible

Ok thanks. I think I may have jumped into things a little too, although I started developing a game before having like a huge amount of knowledge, and I kinda wanna be able to release an early version of it soon. Probably would have been better off learning more before jumping into development.

1 Like

Ok so I’ve updated the script, still not working although I think I’m getting closer.
Here is what my GUI’s look like:
image
I think it’s entirely possible I’ve made a mistake in those.
Here is my script:

local InvenFrame = script.Parent.ToggleButton

local Inventory = script.Parent.InvenFrame

InvenFrame.MouseButton1Click:Connect(function()

if Inventory.Visible == true then

Inventory.Visible = false

else

Inventory.Visible = true

end

end)
1 Like

Change InvenFrame to script.Parent since your script is inside of thebutton

Change Inventory to - script.Parent.Parent.InvenFrame

Also, never put your main script inside of a button, put it inside of the actual GUI so you can have more efficiency and less to worry about.

1 Like

What exactly do you mean? Like can you send a screenshot of the specific area you want me to change because I’m not sure.

Your variables, "InvenFrame"and “Inventory”

The first two lines of code you have, at the top.

We are pretty sure when you meant

You probably meant you gave up before, and not the fact you used to know how to code, You’ll be in better hands to just follow a actual tutorial that explains the logics behind setting up Variables and editing properties within a minute. so i hope you’ll do the following after you resolved this Inventory UI

1 Like

You mean like this?

local InvenFrame = script.Parent
local Inventory = script.Parent.Parent.InvenFrame

Exactly, variables are where you define what you want to use in your code so you don’t have to keep typing those lines out every time you want to get it.

Ok thanks, I’ll probably do that but like you said I should figure this situation out first.
@xRuinedSeven Thanks, I’ll see if it works, and if it does you’re my favorite person for the day.:wink:
EDIT: Hooray! It does work! Thanks!

1 Like

Glad it works for you.

Feel free to check out the resources roblox gives everyone as well.

https://developer.roblox.com

1 Like

I agree with this point, it’s just something you’re going to have to do.

@PotatoStrawberry124

1 Like