Custom Shop Gui Script

Hello My Name is MosesTheRedSea and I 'm new to scripting, this is my first post as well. My main reason for posting this topic is because I wanted to customize my own shop Gui.

There are four panels labeled below on the Shop Gui the Knife, Revolver, Pet and Cash. I wanted the user to be able to click on these panels, and the visibility of each of the frames which I assigned to the panels would either be visible or not based on which the following options the user was trying to select

Here’s the Shop Gui

Here’s the code I put in each of the text buttons

local petShop = script.Parent.Parent.Parent.Pets:GetChildren()

local petFrame = petShop:WaitForChild("PetFrame")

local revolverShop = script.Parent.Parent.Parent.Revolver:GetChildren()

local revolverFrame = revolverShop:WaitForChild("RevolverFrame")

local knifeShop = script.Parent.Parent.Parent.KnifeFrame:GetChildren()

local knifeFrame = knifeShop:WaitForChild("KnifeSale")

script.Parent.MouseButton1Down:Connect(function()

script.Parent.Parent.CashFrame.Visible = true

petFrame.Visible = false

revolverFrame.Visible = false

knifeFrame.Visible = false

end)

Here is the Layout of the Shop Gui

The problem is when I clicked on one of the panels the frame which I assigned to that specific panel wouldn’t appear. It didn’t work for any of the other ones either

I first checked my code because there were some bugs especially when i was pasting it into the different text buttons. I made sure the variable name for the panel actually matched with the frame I assigned it to. But when I tested it again and it still wasn’t working. Finally I thought it was a ZIndex problem, so i changed the buttons for each of the panels to 4 however as it turns out that wasn’t the problem either.

Could you guys help me ?

1 Like

I see your issue. You are a little confused about what “GetChildren()” does. GetChildren() actually returns a table of parts. You cannot use :WaitForChild() on a table, so when you do petFrame = petShop:WaitForChild(“PetFrame”), you are not actually going to get anything. Change all of these:

local petShop = script.Parent.Parent.Parent.Pets:GetChildren()
local petFrame = petShop:WaitForChild("PetFrame")

to this:

local petShop = script.Parent.Parent.Parent.Pets
local petFrame = petShop:WaitForChild("PetFrame")
4 Likes