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 4 years ago

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

script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame.Visible = true
if script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame.Visible == true then script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame.Visible = false
    end
end

2 answers

Log in to vote
0
Answered by 4 years ago

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


local ShopFrame = script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame --For it to be faster script.Parent.MouseButton1Click:connect(function() ShopFrame.Visible = not ShopFrame.Visible end)
0
Short script ieverhart 62 — 4y
0
Thanks! It works! I'll accept it! JustSxript 36 — 4y
Ad
Log in to vote
0
Answered by 4 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.

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

If this helped, be sure to accept my answer!

Answer this question