New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How would I make a script to wait for a specific boolean value?

Asked by 9 days ago

how would I make a script check a boolean value to be true or false before continuing on with the script. Like a waitforchild but for values?

1 answer

Log in to vote
1
Answered by 9 days ago
Edited 9 days ago

There are 2 options

  • Changed

  • GetPropertyChangedSignal


Changed

local boolValue = script.Parent.BoolValue

boolValue.Changed:Connect(function(property)
    if property == "Value" then
        if boolValue.Value == true then
            print("true")
        else
            print("false")
        end
    end
end)

This will run whenever a property changes on the BoolValue (any property) and you would have to check if the property changing is the correct one and the one you want.


GetPropertyChangedSignal

local boolValue = script.Parent.BoolValue

boolValue:GetPropertyChangedSignal("Value"):Connect(function()
    if boolValue.Value == true then
        print("true")
    else
        print("false")
    end
end)

This has already specified which property we are waiting on to change, in this case, we are waiting for the Value property to change.


Hope this helped! Feel free to select this as an answer if this helped you!

0
Oh wow didn’t know that. So if the name changed would it also pass the name? I didn’t know .Changed did more than the Value. SethHeinzman 268 — 8d
0
Yeah, Changed is fired whenever any property of an object is changed. killerbrenden 1306 — 8d
Ad

Answer this question