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

Detecting Value change from a script?

Asked by 12 days 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 12 days 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 10 — 12d
Ad
Log in to vote
0
Answered by
Azarth 2741 Moderation Voter Community Moderator
12 days 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