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.)