When I do this:
if script.Parent.Locked.Value == true then
I get this error:
attempt to index field ‘Locked’ (a boolean value)
I’m sure I’ve been doing it this way forever now, so why can I not do this anymore?
When I do this:
if script.Parent.Locked.Value == true then
I get this error:
attempt to index field ‘Locked’ (a boolean value)
I’m sure I’ve been doing it this way forever now, so why can I not do this anymore?
The problem is you are trying to reference a boolean property “Locked” in parts. If it is a BoolValue, you may need to reference it with :FindFirstChild(“Locked”), or not use Value if you are referencing the property.
Huh, that doesn’t really make any sense to me so I’ll have to reread what :FindFirstChild does. I thought it just would find the first name of whatever.
FindFirstChild returns the first child of that name, or nil. When referencing it with as “Instance.Index”, it will reference the property (Locked) or a child instance.
As an alternative, you could also reference it like this:
if script.Parent["Locked"].Value == true then
Although FindFirstChild
has the benefit of it not erroring if it’s nil.