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

Detecting Value change from a script?

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

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

1 comment

0

no it didn't work

Use the Changed Event

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

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