What do I want to achieve?
I want to make my Gui buttons working basically but it doesn’t go to 31st line.
What is the issue?
Issue is: left blank intentionally - YouTube
(Sorry for small screen it’s something with Nvidia Optimus and it does only run the game itself.)
Basically it makes Float window visible when I click ClassicSword as I wanted but it doesn’t make anything invisible.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I asked other people in communication platforms, looked for solutions on the Developer Hub and added prints, it seems like last if not function is never running and everything is going in else part.
My explorer:
My script:
local frame = script.Parent.Parent
local menus = frame.Parent:FindFirstChild("Menus")
local MainSettings = frame:FindFirstChild("MainSettings")
local ClassicSwordSettings = frame:FindFirstChild("ClassicSword")
local allFrames = frame:GetChildren()
local allMenus = menus:GetChildren()
local function filter(Table, FilterItem)
if not type(FilterItem) == 'string' then
FilterItem = tostring(FilterItem)
end
if type(Table) == 'table' then
for i, v in pairs(Table) do
if v.ClassName == FilterItem then
Table[i] = nil
return Table
end
end
else
assert(false, "This is not a table.")
end
end
filter(allFrames, 'Folder')
filter(allMenus, 'LocalScript')
for _, v1 in pairs (allMenus) do
v1.MouseButton1Click:Connect(function()
for _, v2 in pairs (allFrames) do
if not v2.Name == v1.Name then
v2.Visible = false --This never happens.
else
v2.Visible = true
end
end
end)
end
try outputting the tables after running the filter function, like print(unpack(allFrames)) and print(unpack(allMenus)), maybe they aren’t being setup correctly
you could also print v2 and v1 to check what frames are being checked in both for loops
Check the explorer ingame, maybe you have 2 of this gui shown
and where are you putting if v1 is nil return? if you put it in one of for loops for the MouseClick, it’ll stop the loop from continuing to the next items
for _, v1 in pairs (allMenus) do
if v1 == nil then return end
v1.MouseButton1Click:Connect(function()
for _, v2 in pairs (allFrames) do
if v2 == nil then return end
if not v2.Name == v1.Name then
v2.Visible = false
else
v2.Visible = true
end
end
end)
end
And no, one of their Visible is false as you can see on the video.
try changing if not v2.Name == v1.Name then to if not (v2.Name == v1.Name) then or if v2.Name ~= v1.Name then because incapaxx said that not has a higher precedence over ==
No, ~= is equivalent to ‘is not equal to’, whereas ‘not’ is defined as ‘not’.
Not is a characteristic of boolean logic such that:
if not (condition_1 and condition_2)
means the same as if (not condition_1) or (not condition_2)
So you can achieve a statement where they are equivalent like: if not (type(FilterItem) == 'string' ) and if type(FilterItem)~='string'
but not without parenthesis, not takes preference so: if not type(FilterItem) == 'string' becomes if false == 'string'
Its like the order of operations in math, but with words; ‘not’ is like a negative sign, and ~= is a conditional equality conditional stating two items are not equal.