This is a funny one and it is hard to debug.
Let's review your code. At first glance, there is nothing wrong with it. However, it does not do it's job. Why? We check the output and see that there are no errors. However, setup.Visible
does not appear to be true, YET the window is destroyed. How is that possible? The only possible explanation is that the script stops executing AFTER the window is destroyed, but BEFORE the setup is set to visible. That means that between these operations something happens that stops the script - and it is not an error.
The only possible explanation then is that the script itself has stopped. And yes, this can be explained by the fact that the script is actually IN the window, meaning that the script itself actually gets destroyed when the window is destroyed.
The fixed code will first make the setup visible and then destroy the window.
It is better though to create one script which handles all your GUIs.
01 | print ( "Close button loaded" ) |
04 | window = script.Parent.Parent.Parent.Parent |
05 | setup = Player.PlayerGUI.SetupUI |
08 | function onClicked(GUI) |
12 | script.Parent.MouseButton 1 Click:connect(onClicked) |
Locked by JesseSong
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?