Your scripting is a bit messy and confusing. I would suggest looking into writing a cleaner code. Writing in an organized manner helps us understand your script better and even helps you.
I'll reorganize your script first to show what it should look like, then I'll determine the problem.
local bin = script.Parent
local player = game.Players.LocalPlayer
local mainGui = player:WaitForChild("PlayerGui"):WaitForChild("MainGui")
local updateLogFrame = mainGui:WaitForChild("UpdateLogFrame")
local creatureSelectionMenu = playerGui:WaitForChild("CreatureSelectionMenu"):WaitForChild("CreatureSelectionMenu")
function Clicked()
updateLogFrame.Visible = false
creatureSelectionMenu.Visible = false
mainGui.Visible = true
end
bin.MouseButton1Up:Connect(Clicked)
To begin
Your code is sloppy and I've already addressed that, but it's important to organize it so that we may help you better. While it's not necessarily mandatory, you should set your variables to something relating to their purpose, rather than omg, lol, ded. I took the liberty of renaming them to something more topical. A few key issues: There was a random elseif statement; You called on certain things, even if they weren't completely loaded; You had no end for your elseif statement; etc, etc.
Visible vs Enabled
I noticed that you used Visible. I'm not entirely sure if what you're referencing is ScreenGuis or Frames, but it should be noted that Visible is used for Frames, TextLabels, ImageLabels, etc. Enabled is used for ScreenGuis. Both have the same function, they just apply to different things.
If Statements
This is being addressed due to that random elseif statement.
I'm not entirely sure at its purpose. I think that you were trying to make it so that if the player didn't click, then Gui was not visible? I'm pretty sure that you can not use elseif statements on functions and that they must follow if statements, otherwise you're better off using if statements. As you may know, an if statement asks if something is equal/not equal/ greater than/ etc something. An elseif statement is the follow up. If something does not equal this, does it atleast equal this? An example of its use would be:
local shape = "Square"
if shape == "Circle" then
print("The shape is a circle")
elseif shape == "Square" then
print("The shape is a square")
else
print("I have no clue what the shape is")
end
WaitForChild
It's important to use these when defining variables in the beginning of a script. WaitForChild will literally wait for the item to load. If you don't use this, then you there is a high chance that you will throw an error in a real game. Before you use a WaitForChild, you must use : instead of using .. This is because WaitForChild is an action and not a child of the object. You then follow WaitForChild with ("typetheobjectyou'rewaitingforhere") Make sure that you use parenthesis as most actions require parenthesis.
Finally
All in all, I'm surprised you didn't get any errors, especially considering I ran the script and ran an error. I'm not sure if you're really looking in the correct spot. Also, for future help: I would suggest adding more context to your question, such as what your script does, how it works, where it is, and what kind of script it is (either LocalScript or Script). This will help us understand and help you get fast answers.
If my answer helped you, then please click Accept Answer.
1 comment
Use proper formatting in your posts. Use new lines and code blocks.