I am having a bit of a trouble opening and closing this gui on press.
Question 2: How would I make this script work if it was a segment in a framework? Like what do I do with theonClicked
function if its not that parent.
local button = script.Parent.OpenMenu.Open local frame = script.Parent.Content function onClicked(GUI) frame.Visible = true if not true then return false end button.MouseButton1Click:connect(onClicked)
Or would the function look like this?
local button = script.Parent.OpenMenu.Open local frame = script.Parent.Content button.OnClicked:connect( function(OnClicked) frame.visible = true if true then return false end
I have heard that two equal signs equals the opposite is that true?
frame.Visible = true frame.Visible == false
local button = script.Parent.OpenMenu.Open local frame = script.Parent.Content button.MouseButton1Down:connect(function() frame.Visible = true end)
What's with all the junk?
if true then return false
You don't need that. If you're trying to make it so when you click it for a second time it closes then this should work:
local button = script.Parent.OpenMenu.Open local frame = script.Parent.Content local open = false button.MouseButton1Down:connect(function() if open == false then frame.Visible = true elseif open == true then frame.Visible = false end end)
I don't understand the first part of your question. Perhaps you can refine the question to clarify what you are trying to get at. For the second part of your question regarding '=' and '==' I will explain that.
The first, a single equal sign, is an assignment operator. It takes the result of the expression on the right side of the operator and puts it into the variable on the left side of the operator. This is a simple operator which you will see and use repeatedly. Here are some examples:
local name = player.Name --put the name of the player into a variable called name local sum = x + y --adds x to y and places the result in a variable called 'sum' local selected = nameIsSet and stillAlive -- if both nameIsSet and stillAlive are true, selected becomes true
Two equal signs is another operator entirely. It is a relational operator, that is, it compares the relationship between two things. In that sense, it is similar to these operators: >, >=, <, <=
In this case the "==" operator checks whether two things are the same thing. Here are some examples:
local sameNumber = 2 == 2 --the variable `sameNumber` gets the value `true` because 2 is equal to 2 local sameName = playerName == player.Name -- sameName will be false if the value in playerName is not the same as player.Name frame.Visible = frame == v.frame --In this case, first frame is compared to v.frame. If they are the same thing (if they are equal to each other), then the result of that expression is `true` and therefore Visible gets the value `true`
Here is an article on relational operators in Lua