Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

0

Short script

0

Thanks! It works! I'll accept it!

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.