Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Open and close GUI button not working! Is there a fix to this?

Asked by 3 years ago
Edited 3 years ago

So recently I have been following a guy named AlvinBlox's tutorials, and this based on a sword fighting series. Someone already asked this question but the question got closed. So basically, there is a button named ShopButton (yes it has a variable to it) and basically in the GUI there is a localScript called "Core" where you put all the coding. Basically, I coded the button ("ShopButton") to where when you click it, it toggles the GUI close and open (Visible and not Visible) but when I tested it, it didn't work. Here is the line of code: shopButton.MouseButton1Click:Connect(function() mainFrame.Visible = not mainFrame.Visible

So another thing I didn't mention is that the "mainFrame" is the GUI just note that. And so the problem is, it doesn't work. So basically that code I just mentioned basically what it does is if the GUI is open then when you click the button it will close it, and when it is closed, when you click it, it will open. So it doesn't work I have tested it multiple times. I can't go on the DevForums because I am not a member. Does anyone have a fix to this problem?

local availableTools = game.ReplicatedStorage:WaitForChild("GetTools"):InvokeServer()
local mainFrame = script.Parent:WaitForChild("MainFrame")
local safeArea = mainFrame:WaitForChild("SafeArea")
local itemInformation = safeArea:WaitForChild("ItemInformation")
local infoFrame = itemInformation.InfoFrame
local selectedItem = itemInformation.SelectedItem
local equippedItem = itemInformation.EquippedItem
local numberOfItems = #availableTools

local itemFrame = safeArea.ItemFrame
local shopButton = script.Parent:WaitForChild("ShopButton")
local buyButton = infoFrame.BuyButton
local equippedItemViewport = script.Parent:WaitForChild("EquippedItemViewport")
local itemViewport = itemInformation.ItemViewport


shopButton.MouseButton1Click:Connect(function()
    mainFrame.Visible = not mainFrame.Visible
end     

That is all the code in the core script. (A localScript.) Here are the details in explorer, I will try to type them out as neat as possible.

\/ StarterGui \/ Shop

EquippedItemViewPort (Ignore that) Core (localScript) ShopButton (Button/TextButton) And >MainFrame (The frame, but it's just called MainFrame.)

0
You need to provide more information, as we can't really help with just this alone. Provide visuals of your explorer, and gui properties. Try to debug your code .Add a print in to see if the click registers or not. Perhaps your zindex is lower then something else. or something along the lines of that. Xx_FROSTBITExX 116 — 3y
0
I showed them! DestroyDecember12 0 — 3y
0
Check for any errors. RobloxGameingStudios 145 — 3y
0
You clearly didnt read all of FROSTBITE's comment. RobloxGameingStudios 145 — 3y

Answer this question