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

Script not detecting if a BoolValue is changed?

I'm trying to make a theme park ride with a motor for the thing that holds you in the ride. So I added weldconstraints, the script enables the weldconstraints so that it holds the motor because it would glitch out when the ride is in motion. I have tested this without the script works perfect. But for some reason the script wont detect the boolvalue when it is changed.

Btw the scripts inside a model

Here's the script:

Hold = script.Parent.Parent.Parent.Parent.Hold

Hold.Changed:Connect(function()
	print("ugh") --This word wont print
	if Hold.Value == true then
		script.Parent.Enabled = true
	end
	if Hold.Value == false then
		script.Parent.Enabled = false
	end
end)

4 comments

0

do you get any error?

0

Are you changing the bool value in a Server Script or a Local Script ?

0

Its a script inside a model in workspace, no errors

0

I'm having the same thing, I was making a remote event test game before and I made a TextLabel that would say true when the BoolValue is true, and would say false when the BoolValue is false. I was trying to get a Touched and TouchEnded thingy, you know.

1 answer

You need to use script.Parent.Enabled.Value, which changed the value of the boolean, else it does not change the value, just the boolean value itself so use:

Hold = script.Parent.Parent.Parent.Parent.Hold

Hold.Changed:Connect(function()
    print("ugh") 
    if Hold.Value == true then
        script.Parent.Enabled.Value = true --Need to access .Value to change the value of any variable
    end
    if Hold.Value == false then
        script.Parent.Enabled.Value = false
    end
end)

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