How to use a boolValue?

Good morning!, Today I want to learn how to use the book value but when I look for information, it does not appear how to use it. Can anyone explain to me how to use it and some short examples?

1 Like

Bool value contains boolean values which are either true or false.

2 Likes

A BoolValue object, just like other kinds like IntValue, NumberValue and StringValue, stores a boolean value. You can see this for settings or sharing information across the place.

1 Like

You could have a script parented to one and for example:

if script.parent.Value == true
Then print("Value is true")
else 
print("value is false") 
end

And depending if the little box in the boolvalues properties was checked, it would either print true or false on run!

5 Likes

For some reason it gives me an error in =

Should be == instead of = probably an expression mistake.

4 Likes

Well, I think I got the hang of this BoolValue thing. Thanks everyone!

This might not always be up to date so you’d probably need to use .Changed to check

1 Like

It’s true, I just applied it. Thank you!

@SpeedySanikJr made a typo. It should be ==. = is used to set something, like potato = true but == is used to check a value, like if potato == true then

3 Likes

Oops mb…

Fixed it yeah sorry again.

This could become useful for checking at certain points if a player has completed a task, or using the .Changed to give a player an item when they do something. As @offizen said, but for just the basics of learning, glad to help!

1 Like