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

If statement that checks for changed values?

The script checks for BoolValues and whether its true. But it only checks once, when the game starts up. When the values are later changed, it doesn't do its job and it becomes a problem. I wasn't sure how to fix this.

if val1.Value == true and val2.Value == true and val3 == true then
	print("Hello")
end

2 comments

0

"if something == true then" is redundant unless the type might be something other than a boolean. Instead, use "if something then."

2 answers

Hi, there should be a function for BoolValues called “ :GetPropertyChangedSignal() “ which detects if a property has been changed which you need to specify in the brackets.

Example:

local bool = workspace.BoolValue

bool:GetPropertyChangedSignal(“Value”):Connect(function()
    print(“Bool’s value has changed!”)
end)

Hope this helped!

5 comments

0

pretty sure all instances have that function

0

and how did you get your strings like that? :p

0

lol

0

It is not a function, it is a method.

0

Here the Changed event would be better, since it also passes the new value as the argument.

You could use the :Changed() property and I believe it will work the same depending on what you do.

1 comment

0

BoolValues also have GetPropertyChangedSignal()

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