|
| 07 Feb 2017 04:22 PM |
How do I get the boolean value from a property?
I'm trying to check if something is visible or not (GuiObject). I know I can use an 'if statement', but I'm trying to avoid that.
When I run the following command: print(Frame.Visible) The output in 'nil'. How do I get the Frame's 'Visible' property without 'if statements'?
Thanks.
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:23 PM |
just reference the property? it should work fine...
|
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:23 PM |
What do you mean by that? Example please.
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
Majarite
|
  |
| Joined: 14 Jan 2017 |
| Total Posts: 394 |
|
|
| 07 Feb 2017 04:24 PM |
You can access the property like normal?
What's wrong with an if statement?
|
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:24 PM |
post the whole script where trying to access Frame.Visible returns nil
|
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:26 PM |
No need. Just assume 'Frame' is a valid variable of which it's ClassName is also 'Frame'.
As for 'if statements', it takes up unnecessary space for what I'm doing.
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:28 PM |
you're clearly doing something incorrectly, it would either return true or false
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 07 Feb 2017 04:29 PM |
| $100 that Frame is a table |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:31 PM |
I'm 100% sure I'm not doing anything wrong. Printing a boolean results in a nil value by default. This is why something like NumberValue.Value requires '.Value' at the end. Property values don't have this, though.
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:32 PM |
It's not a table.
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:32 PM |
"This is why something like NumberValue.Value requires '.Value' at the end."
that's entirely incorrect. NumberValue is the object itself and Value is the property
post your script so cnt can get his 100
|
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:35 PM |
I'm trying to print the property's value. There's no reason to post my script. It's as simple as pathing to the Frame's 'Visible' property. If you print a NumberValue alone, you'll receive its name, not it's value. I'm talking about a property of a non-Value object.
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:36 PM |
In fact, why don't you try to print a frame's visible property? Tell me what you get (without using if statements).
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:36 PM |
I'm done replying here until you post the code
|
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:38 PM |
Like I said, you try to print a frame's visible property and tell me what you get. I'm not a newbie for god's sake.
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 07 Feb 2017 04:40 PM |
print(player.PlayerGui.ScreenGui.Frame.Visible)
|
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:41 PM |
Btw, why would it matter even if it was in a table?
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 07 Feb 2017 04:42 PM |
> scripter does something wrong > refuses to blame it on himself > says some stupid things
bro.... this aint originality |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:46 PM |
Turns out that I didn't even have a Frame inside the ScreenGui. Don't ask how I messed that up.
cnt, if you're not going to help, leave.
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 07 Feb 2017 04:49 PM |
No, the problem was that you were trying to index "Visible" of a table. No matter where the GuiObject is, fetching the Visible property will only ever return true or false. |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:49 PM |
just a pointer next time you're trying to get help: don't be stubborn and actually post the code so you don't make a 20-reply thread of people trying to troubleshoot over an error as simple as this
|
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:52 PM |
cnt, I was writing something that checks for the contents of a list of guis. The one I was selecting was an empty test ScreenGui.
You still haven't answered my question, though. Why would it matter if it were in a table?
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:53 PM |
@Unsubtleties
I've been here many years. I post my code when I'm not confident in what I'm doing.
~MightyDantheman~ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 07 Feb 2017 04:54 PM |
I'm saying if `Frame` is a table then chances are there is no value mapped to by a key named `Visible`.
It's impossible to get nil when you're indexing a boolean property. If the property doesn't exist: you get the child or and error. If it does exist, you're guaranteed the type it holds. In the case of `Visible` it would always be either true or false, never nil. |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2017 04:54 PM |
"I post my code when I'm not confident in what I'm doing." stop being confident
|
|
|
| Report Abuse |
|
|