directory.Open.MouseButton1Click:Connect(function()
for i,v in pairs(directory:GetChildren()) do
if v.Name == "Open" then
--do nothing
elseif
v:IsA("LocalScript") then
-- do nothing
else
v.Visible = true
end
end
end)
Youre running multiple ifs and not doing anything with them.
Just do
--Typed on mobile
if v.Name ~= "Open" and not v:IsA("LocalScript") then
v.Visible = true
end
Critiquing the consistency here, using ~= and not in the same line. I would change it to
if not(v.Name == "Open" or v:IsA("LocalScript")) then
~= is comparing strings, not is a boolean comparator. Boat was completely correct
Though that works I think that he was saying from a readability standpoint it’s better to do this:
not(v.Name=="Open" or v:IsA("LocalScript"))
Than it is to be doing this:
(not v.Name == "Open" and not v:IsA("LocalScript"))
I don’t entirely agree with how you phrased that.
As ~= returns either true or false I would consider stringA ~= stringB
to effectively be a boolean in and of itself, and so the way he’s written is is equivalent to
if not booleanA and not booleanB then
which would be written better as
if not(booleanA or booleanB) then
You all make valid points. However, any performance differences are miniscule, and this is just a readability and style issue.
Everyone can simply go with what works for them. I still like the way I wrote it, because it reads very easily (for me).
If you prefer it that way, then fair enough - I was just proposing best practices for the forums
You can’t compare strings with “not”
I never said you could?
I was saying that stringA ~= stringB
is the same as not(stringA == stringB)
, and was giving styling practices based off of that
I see what you meant. My bad.
Are you sure that you can use distribute property here? I can’t recall, haha
I’m afraid I don’t understand your question