Hello, I made a script short ago which would show a gui. It worked. This is the script that worked:
script.Parent.OpenedStoreFrame.BackgroundTransparency = 1
function leftClickopenStore()
if script.Parent.OpenedStoreFrame.BackgroundTransparency == 1 then
print("BGTransparency to 0")
script.Parent.OpenedStoreFrame.BackgroundTransparency = 0
elseif script.Parent.OpenedStoreFrame.BackgroundTransparency == 0 then
script.Parent.OpenedStoreFrame.BackgroundTransparency = 1
print ("BGTransparency to 1")
end
end
script.Parent.StoreFrame.StoreButton.MouseButton1Click:Connect(leftClickopenStore)
Then, my friend told me i could do it on a more easy way. I remade the script, but with a specific close button. First the open button was also the close button. But this script didnt work:
-- Defines GUI objects of store --
local OpenedStoreFrame = script.Parent.OpenedStoreFrame
local StoreText = script.Parent.OpenedStoreFrame.TextLabel
local CloseButton = script.Parent.OpenedStoreFrame.CloseButton
local VipGamepassIcon = script.Parent.OpenedStoreFrame.VipGamepass
local StoreOpenButton = script.Parent.StoreFrame.StoreButton
-- Makes store gui objects invisible at start of game --
OpenedStoreFrame.Visible = false
StoreText.Visible = false
CloseButton.Visible = false
VipGamepassIcon.visible = false
StoreOpenButton.visible = true
-- WORKING PART STOPS HERE --
-- Defines store button click functions --
script.Parent.StoreFrame.StoreOpenButton.MouseButton1Click:Connect(OpenStoreClicked)
script.Parent.OpenedStoreFrame.CloseButton.MouseButton1Click:Connect(CloseStoreClicked)
-- Defines store button function and detects click --
function OpenStoreClicked()
if OpenedStoreFrame.Visible == false then
OpenedStoreFrame.Visible = true
StoreText.Visible = true
VipGamepassIcon.Visible = true
CloseButton.Visible = true
StoreOpenButton.Visible = false
print("StoreGUIVisible")
end
end
-- Defines store closing button function and detects click --
function CloseStoreClicked()
if CloseButton.Visible == true then
OpenedStoreFrame.Visible = false
StoreText.Visible = false
VipGamepassIcon.Visible = false
CloseButton.Visible = false
StoreOpenButton.Visible = true
print("StoreGUIHidden")
end
end
It didnt work. We tried a local script, removing the local tags in front of the variables, and much more, but it didnt work. How can i get this to work? did i make a mistake in the code? also, the button click wasnt detected at all because the print text wasnt shown in the output.

3 comments
I dont really get it, in the second script, the non working script, the functions are before the events right?
No. These need to be defined before the event happens.
Not only that, your other version was much simpler, might want to revert to that one.