Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why can't I change my bool value?

Asked by 7 years ago

for some reason this won't work...

button = script.Parent
isSelected = button.Selected -- this is a bool value

isSelected.Value = false

error:Players.Player1.PlayerGui.WeaponsGui.WeaponsFrame.ClassFrame.SelectClass.Class1.LocalScript:6: attempt to index field 'Selected' (a boolean value)

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

The problem is funny, actually. Considering you're trying to manipulate a BoolValue. It makes the error difficult to decipher.

Since 'button' is a TextButton, and 'Selected' is actually a property of TextButtons.. when you define 'isSelected' on line 2 the script thinks you're defining a variable based off of the Property's value.

So.. when you try to index 'isSelected' on line 4, the script essentially thinks you're trying to do "true.Value = false".

To fix this you're gonna have to simply change the name of the 'Selected' object.

button = script.Parent
isSelected = button.isSelected --Change the object's name to "isSelected"

isSelected.Value = false
Ad

Answer this question