This gui closing script isnt working properly and I dont know why

if you put a line in front of the return local function it doesn’t print the first time

only works properly after you open and close a different gui
which is what we are confused about.

Hm are you sure everything else that is in front of it has its visibility is set to false

Note also that we have another exit script which is the exact same as the inventory one is, and it works just fine. we have compared them and they have no visible difference in them, but the inventory close doesn’t work, and the other close button/script does.
it only works upon being opened a second time. not the very first time

Try exitbutton.MouseButton1Click

Also you can try

ExitButton.MouseButton1Click:Connect(function()

leftClick()

end)

didn’t change anything

still doesn’t detect it the first time.

instead of making a wall of tweens, you should loop through all of the elements instead

local TS = game:GetService("TweenService")
local tInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

local Inventory = script.Parent.Parent
local Exit = script.Parent

can_open = Inventory.OpenClose

Exit.MouseButton1Click:Connect(function()
  if can_open.Value then return end
  can_open.Value = false
  local Tween

  for _, Item in Inventory:GetChildren() do
    local Properties = {}
    if Item:IsA("ScrollingFrame") then Item.Visible = false continue end
    if Item:IsA("TextButton") then Properties = {["BackgroundTransparency"] = 1, ["TextTransparency"] = 1} end
    if Item:IsA("ImageLabel") then Properties = {["ImageTransparency"] = 1} end
    Tween = TS:Create(Item, tInfo, Properties)
    Tween:Play()
  end 

  Tween.Completed:Connect(function()
    Inventory.Visible = false
  end)

  -- I'm assuming you have another script that sets can_open to true
  -- You're able to move it into a single script if this is true ^
end)
2 Likes

Gezz this is getting serious …

Ok I see you’re starting out with everything not visible then tweening them in.
Set that button to visible in the explorer window. So it starts off visible when the code is initializing when the program 1st starts, even though you can’t see anything yet (it hasn’t been opened). Then use the code to set it to not visible, so you can tween in like you are.

2 Likes

The only things not set to visible is the different windows you can open by pressing the different buttons on the gui. Nothing else has it’s visibility set to false.

so it has no effect on the exit button

Take away the tween-in and try it. (trying to isolate the problem here.)

Tried the script you purposed and it makes the script not work at all when it comes to closing. While looking through your script and seeing it’s the same as the one we have just more compact and neater look wise, it makes even closing the inventory after opening it a second time not possible, while it was possible previously.

Our problem is rather strange as nothing changes with the script when being opened a second time, but closing it works only the second time around and every time after, but the very first time the inventory is opened as the first gui window opened, it doesn’t want to close unless you open a different gui which forcefully closes the inventory.

Have tried fail checking the script in many ways and have figured out that what it doesn’t detect is the action of clicking the close button the first time inventory is opened only when the inventory is the first gui opened.

I checked this by adding a print to right after the script checking for the leftclick, and upon clicking it after having the inventory being the first gui you open, nothing happens and the print isn’t even sent.

If you then open a different gui and go back to the inventory, the inventory close works and the print detects the click.

you should read the comment i wrote on the script
i already assumed this would be an issue since i have no idea what your full script/scripts look like (i wasn’t really reading the post, only cleaning the code)

also instead of doing ‘local Tween’ 50 times you could remove it

TS:Create(Backround, tInfo, {["ImageTransparency"] = 0}):Play()
HatsFrame.Visible = false -- Set booleans without tweening
2 Likes

Open it and then close it with the script real quick. So their 1st time opening it is actually the 2nd time it’s been opened. (oh ya I’m reaching now) without the tween on your fake open or super fast tween. You got about 3 seconds before anything can be seen on screen as it’s still loading. Make sure the watforchild() are in place however. Or start with it open and close it before the game screen comes into view.

2 Likes

We tried to make use of the code in one script however it doesn’t work sadly. Thank you for the suggestion.

As for the removing of the tweening for visibility being false, we’ve changed that now.

Have you tried doing it without the tween at all to isolate the problem.

Have tried making it so it opens and closes once before the player has a chance of clicking on it and it doesn’t change anything. Thank you for suggesting this.

i’ll try using no tween now…

To jay for saying if we’ve tried to do it without the tweening to isolate the problem. We have tried to remove the tweening from the script all together, and it doesn’t change the outcome at all.

i had a similar problem i ended up having to make it server side by firing a remote event
to open and close it since the server doesn’t know if its closed on the client or not

not sure if it will work with the tween tho

We have already tried sending a local script firing a remote to a server sided script and it didn’t work at all.

hm weird can you make a simple game with the gui in it so i can debug it easier?