How do i get this button script with local variables working again?
Hello,
I made a script short ago which would show a gui. It worked.
This is the script that worked:
01 | script.Parent.OpenedStoreFrame.BackgroundTransparency = 1 |
02 | function leftClickopenStore() |
03 | if script.Parent.OpenedStoreFrame.BackgroundTransparency = = 1 then |
04 | print ( "BGTransparency to 0" ) |
05 | script.Parent.OpenedStoreFrame.BackgroundTransparency = 0 |
06 | elseif script.Parent.OpenedStoreFrame.BackgroundTransparency = = 0 then |
07 | script.Parent.OpenedStoreFrame.BackgroundTransparency = 1 |
08 | print ( "BGTransparency to 1" ) |
13 | script.Parent.StoreFrame.StoreButton.MouseButton 1 Click: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:
02 | local OpenedStoreFrame = script.Parent.OpenedStoreFrame |
03 | local StoreText = script.Parent.OpenedStoreFrame.TextLabel |
04 | local CloseButton = script.Parent.OpenedStoreFrame.CloseButton |
05 | local VipGamepassIcon = script.Parent.OpenedStoreFrame.VipGamepass |
06 | local StoreOpenButton = script.Parent.StoreFrame.StoreButton |
08 | OpenedStoreFrame.Visible = false |
09 | StoreText.Visible = false |
10 | CloseButton.Visible = false |
11 | VipGamepassIcon.visible = false |
12 | StoreOpenButton.visible = true |
17 | script.Parent.StoreFrame.StoreOpenButton.MouseButton 1 Click:Connect(OpenStoreClicked) |
18 | script.Parent.OpenedStoreFrame.CloseButton.MouseButton 1 Click:Connect(CloseStoreClicked) |
20 | function OpenStoreClicked() |
21 | if OpenedStoreFrame.Visible = = false then |
22 | OpenedStoreFrame.Visible = true |
23 | StoreText.Visible = true |
24 | VipGamepassIcon.Visible = true |
25 | CloseButton.Visible = true |
26 | StoreOpenButton.Visible = false |
27 | print ( "StoreGUIVisible" ) |
32 | function CloseStoreClicked() |
33 | if CloseButton.Visible = = true then |
34 | OpenedStoreFrame.Visible = false |
35 | StoreText.Visible = false |
36 | VipGamepassIcon.Visible = false |
37 | CloseButton.Visible = false |
38 | StoreOpenButton.Visible = true |
39 | print ( "StoreGUIHidden" ) |
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.