Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why can't I change my bool value?

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.