Trying to make a Shop And Menu GUI but failed

Hello! Im trying to make a menu Gui

But when I was finished the scripts didn’t open or close the shop at all please help

I Was doing a video tutorial on YouTube but I cant get In contact with the person who originally made it and I cant find anything on the dev forum about this.

< Scripts >

Shop Visible Script

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.ShopFrame.Visible = true
end)

Shop Invisible Script

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent = false
end)

< Images >


image

2 Likes

Fixed the script for you.

Shop Visible Script

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.ShopFrame.Visible = true -- You tried to get ScreenGui and find ShopFrame for it, but you missed an extra "Parent".
end)

Shop Invisible Script

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Visible = false -- You forgot to put Visible
end)

If that doesn’t work, it looks like you’re using the same open button to close. Then you have to use MouseButton1Up, or MouseButton1Down. Like:

Shop Visible Script

script.Parent.MouseButton1Up:Connect(function()
	script.Parent.Parent.Parent.ShopFrame.Visible = true
end)

Shop Invisible Script

script.Parent.MouseButton1Down:Connect(function()
	script.Parent.Parent.Visible = false
end)
1 Like

There’s really no need for 2 connections, instead you can use if statements to check if the Shop is already visible and if so, it makes it invisible, and that for when It’s invisible too.

The script would look like this:

local ShopFrame = script.Parent.Parent

script.Parent.MouseButton1Click:Connect(function()
if ShopFrame.Visible == true then
	ShopFrame.Visible = false -- If shop is already visible then it makes it invisible.
else
	ShopFrame.Visible = true -- If shop is invisible then it turns visible.
end)
2 Likes

It doesnt work I tried clicking it but nothing happens

Wait do I make it so their in the same script?

Yes, it would be a single localscript, that would contain that exact script I posted.

1 Like

He has two separate buttons for showing and hiding the ShopGui.

2 Likes

Yea thats what made me a little confused

Ohh yeah, My bad.

Then it wouldn’t be in a single script, at your localscript called “Shop Invisible” there should be this script:

local ShopFrame = script.Parent.Parent

script.Parent.MouseButton1Click:Connect(function()
	ShopFrame.Visible = false
end)

In your “Shop Visible” localscript there should be this:

local ShopFrame = script.Parent.Parent.Parent.Parent.ShopGui.ShopFrame -- There's easier way to locate this

script.Parent.MouseButton1Click:Connect(function()
	ShopFrame.Visible = true
end)
1 Like

The shop close Gui works now but the open one is still haywire

That may be because the ShopFrame screenGui has not loaded yet, so using WaitForChild we will actually wait until it loads it, which is what we need.

Change local ShopFrame to this:

local ShopFrame = script.Parent.Parent.Parent.Parent:WaitForChild("ShopGui").ShopFrame

no still doesnt work I dont see any errors

Really? Let’s try checking if you’re really getting the ShopFrame.

Change the connection to this and tell me if it prints something out.

script.Parent.MouseButton1Click:Connect(function()
    print("ShopFrame Visible: "..ShopFrame.Visible)
	ShopFrame.Visible = true
end)

FOUND IT

In the output theirs random errors

From what I saw in your first image you should be executing the localscript from ShopButton and It’s name is “Shop Visible” so this error doesn’t seem to be coming from that localscript, but from one located in PlayButton.

Were those the only errors in the Output? Are you sure nothing printed correctly?
Check if there are any errors related to “ShopButton.Shop Visible”

12:55:42.211  Hello world!  -  Server  -  Storz Currency:1
12:55:45.226  Players.NubblyFry.PlayerGui.ShopGui.ShopFrame.TextLabel.Tix Currency Counter:7: Expected <eof>, got 'end'  -  Studio  -  Tix Currency Counter:7

Those errors seem unrelated to “ShopButton.Shop Visible” though, can you see if there’s any errors or anything coming from that localscript? (The Shop Visible one)

If there’s absolutely nothing coming from the ShopVisible localscript then that probably means the MouseClick connection is not even firing, so make sure to check if It’s actually getting triggered.

1 Like

WOO1:Unknown Global ‘shopframe’

I managed to fix it myself, heres the script now that it works

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	player.PlayerGui.ShopGui.ShopFrame.Visible = true
end)

Thanks for trying to help!