hello everyone, I created a script when you press the button, it closes the icons, but it works for me when I press it, it closes and when I press it again, it does not open my script
local visible = game.StarterGui.GamepassShop.Parent.CodeGui
script.Parent.MouseButton1Click:Connect(function()
if visible then
script.Parent.Parent.Parent.GamepassShop["Open/Close"].Visible = false
script.Parent.Parent.Parent.CodeGui["Open/Close"].Visible = false
script.Parent.Text = "<<<"
else
script.Parent.Parent.Parent.GamepassShop["Open/Close"].Visible = true
script.Parent.Parent.Parent.CodeGui["Open/Close"].Visible = true
script.Parent.Text = ">>>"
end
end)
Is this what you meant to do on the first line? (You forgot .Visible)
local visible = game.StarterGui.GamepassShop.Parent.CodeGui → .Visible
(Considering that if “CodeGui” is a frame.)
I think I spotted the problem, so when you close it, it doesn’t re-open it? I believe it’s because you’re getting the Ui that’s currently in starter GUI not in the person’s player GUI.
game.Players.PlayerAdded:Connect(function(Player)
local visible = game.Players[Player.Name].PlayerGui.GamepassShop["Open/Close"].Parent.Parent.CodeGui["Open/Close"]
-- [[ I don't know the parents of each file, so you're gonna have to edit from here on your own, sincerely sorry. ]] --
--------------------------------------------------------------------------------------------------------------------------------------
script.Parent.MouseButton1Click:Connect(function()
if visible then
script.Parent.Parent.Parent.GamepassShop["Open/Close"].Visible = false
script.Parent.Parent.Parent.CodeGui["Open/Close"].Visible = false
script.Parent.Text = "<<<"
else
script.Parent.Parent.Parent.GamepassShop["Open/Close"].Visible = true
script.Parent.Parent.Parent.CodeGui["Open/Close"].Visible = true
script.Parent.Text = ">>>"
end
end)
end)
I don’t really know how the UI looks and how it is made, sorry that I’m a bit annoying, but may you send a screenshot of the UI? (NOT THE UI ITSELF, BUT IN THE EXPLORER), and where the script is placed inside, so therefore I cannot do more than give you the fix to the code, although I never said I’ll leave without attempting atleast to solve the problem.