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

Detecting Value change from a script?

Asked by 4 years ago

I have a script in a part thats in workspace. In that part I have a boolvalue and a script and I want the script to detect when the boolvalue is true.

code in script

while true do
    if script.Parent.Value.Value == true then
        print("OMG IT WORKED")
    end
    wait()
end

Isn't working, please tell me why

2 answers

Log in to vote
0
Answered by 4 years ago

I think the problem is because you aren't providing the boolvalue's name in the script, try switching the first .Value for .BOOLVALUENAMEHERE like this:

while true do
    if script.Parent.BOOLVALUENAMEHERE.Value == true then
        print("OMG IT WORKED")
    end
    wait()
end
0
no it didn't work ewdoggypoopoo 12 — 4y
Ad
Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
4 years ago

Use the Changed Event

script.Parent:WaitForChild("Value").Changed:Connect(function(newvalue)
    if newvalue then 
        print("OMG IT WORKED")
    end
end

Answer this question