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

Why isn't the frame getting invisible when I press the button again?

Asked by 5 years ago

I have no clue what I am doing wrong please help me, thanks

1script.Parent.MouseButton1Click:Connect(function()
2script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame.Visible = true
3if script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame.Visible == true then script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame.Visible = false
4    end
5end

2 answers

Log in to vote
0
Answered by 5 years ago

Do you want help with the script? I got the script right here for you:

1local ShopFrame = script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame --For it to be faster
2script.Parent.MouseButton1Click:connect(function()
3        ShopFrame.Visible = not ShopFrame.Visible
4    end)
0
Short script ieverhart 62 — 5y
0
Thanks! It works! I'll accept it! JustSxript 36 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

You were constantly updating the Frame to be visible everytime someone clicked the button by including it in the function. This script fixes that.

1local ShopFrame = script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame --Indexes placement of Frame
2ShopFrame.Visible = true --Here we can change the Frame to be visible during the start
3script.Parent.MouseButton1Click:Connect(function() --When a player hits a button
4if ShopFrame.Visible == true then --If visible then
5    ShopFrame.Visible = false --Change it back to false
6elseif ShopFrame.Visible == false then --If invisible then
7    ShopFrame.Visible = true --Change it back to true
8    end
9end)

If this helped, be sure to accept my answer!

Answer this question