if not v.ZIndex == "-1" then v.Visible = false end
When I put a "not" nothing changes, anyone know how to use not?
The reason for this is because the GuiObject.ZIndex
property holds an integer
value, and you attempted to compare it to a string
, which will return false. Simply make it -1
and it will be good from there.
In Lua, anything but false
or nil
is truthy. So numbers, strings and tables are all examples of truthy values. The boolean true
itself is also truthy. If you print(not 5)
, that would print false
, as you're inverting the "truthiness" of the number. So by you doing if not v.ZIndex == "-1" then
, you're actually just saying if false == "-1" then
. In order to fix this, you can wrap the v.ZIndex == -1
in brackets, or make your ==
an ~=
.
if not (v.ZIndex == -1) then ----OR---- if v.ZIndex ~= -1 then
not
only works for booleans, not if the condition is not met.
Try this instead. ~=
means not equal to.
I quit the ""
, because the ZIndez is a number, not a string.
if v.ZIndex ~= -1 then v.Visible = false end