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

Why isn't my GUI disappearing and reappearing when it's told too?

Asked by 5 years ago

So I scripted this local script in my shop GUI to pop up when you click it. (there are three parts to the shop GUI; Swords, Effects, and Coins). So that way when you click one of the (Swords, Effects, and coins) GUIs the list of items would pop up. I thought I got everything right but I was wrong.

Swords = script.Parent.Parent.Swords
Sword = script.Parent.Parent.Sword
Effects = script.Parent.Parent.Effects
Effect = script.Parent.Parent.Effect
Coins = script.Parent.Parent.Coins
Coin = script.Parent.Parent.Coin

visible = false

Swords.MouseButton1Down:Connect(function()
 if visible == false then
  Sword.Visible = true
  visible = true


end
Effect.Visible = false  -- these two lines of code tell the other guis to close when this gui is opened
Coin.Visible = false
end)

When I press the button the gui will pop up and the others disappeared but after clicking it multiple times it wouldn't work. (BTW I am new to scripting so thanks.) I put this local script in every button but I just changed the Coins and Swords and effects. Thank you! If you need more details I'll give more details.

When I press the button the gui will pop up and the others disappeared but after clicking it multiple times it wouldn't work.

Link to a video with more details: (http://drive.google.com/file/d/1PnznmaG1j_8U8jIJpnJ_WcaZrOME-Oay/view?usp=sharing[])

0
So judging from the video, you want to toggle the visibility of each gui? SteamG00B 1633 — 5y
0
Also, is this the full script for the guis or is there more than this? SteamG00B 1633 — 5y
0
Yes there is only one script for the Coin, Sword, or Effect button but, there is the same local script in the button. However, I changed lines 10, 17, and 18 to fit that button. sbob12345m 59 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You've forgotten to turn the visible thing off again if it's pressed when it's showed. This should work:

Swords = script.Parent.Parent.Swords
Sword = script.Parent.Parent.Sword
Effects = script.Parent.Parent.Effects
Effect = script.Parent.Parent.Effect
Coins = script.Parent.Parent.Coins
Coin = script.Parent.Parent.Coin

visible = false

Swords.MouseButton1Down:Connect(function()
 if visible == false then
  Sword.Visible = true
  visible = true


end
Effect.Visible = false  -- these two lines of code tell the other guis to close when this gui is opened
Coin.Visible = false
visible=false
end)

cheers!

Ad

Answer this question