BoolValue.Changed

I’m trying to use the .Changed Event on a BoolValue but it’s not working.

script.Parent.BoolValue.Changed:Connect(function()
print("Changed")
end)

I have also tried BoolValue.Value.Changed but that also doesn’t work.

1 Like

Do you get any output in the console?

1 Like

attempt to index boolean with ‘Changed’

2 Likes

What about this:

script.Parent.BoolValue.Changed:Connect(function(NewValue)
    print(NewValue)
end)

If the script is a Script instead of a LocalScript and you are changing the value after pressing “Play” in studio, then it will not work because any changes made as a Player will be local instead of server-side. Instead, try to press “Run” under the ‘Test’ Tab > ‘Simulation’ section > ‘Run’:

image

And then change the value of the BoolValue in the explorer.

2 Likes

Can you show us your tree in the explorer?

2 Likes

That wouldn’t work because I need it to be local.

2 Likes

Then do it with :GetPropertyChangedSignal("Value") because else it doesn’t work in a LocalScript.

5 Likes

Use this instead, using changed isn’t as promising as GetPropertyChangedSignal.

script.Parent.BoolValue:GetPropertyChangedSignal("Value"):Connect(function()
  print("Changed")
end)
3 Likes

Who told you that? Whoever did lied to you big time. You can use changed events in a local script.

1 Like

Why not, there is no difference in their functionality

2 Likes

Yes however, changing to GetPropertyChangedSignal has worked for me better in recent times. I’m not sure why, but it just does.

2 Likes

Scripting Master Ching Cheng Pie.
No, try it yourself, it won’t work.

1 Like

For BoolValue, :GetPropertyChanngedSignal() doesn’t need to be used as the .BoolValue.Changed event returns the Value by default.

2 Likes

Lol, I use .Change events in local script anytime I make UI for stats. I always use .Change (mostly on Number/Int values but it works for all )

3 Likes

Yep, this doesn’t only go for BoolValues but anything ending in value (ex IntValue)

2 Likes

Hm, then it’s weird how it doesn’t work for the person who made this thread. GetPropertyChangedSignal, isi clearly working for him as he marked it as the solution.

3 Likes

Actually it was probably cause he didn’t put NewValue inside of the ().

1 Like

This is probably a special edge case or simply a bug. Though,

I have seen that .Changed is less reliable and isn’t firing every time as of recently. (Not just on Value objects, on any Instance)

1 Like

GetPropertyChangedSignal() should not be used for ValueObjects. The benefit of the Changed signal of ValueObjects is that it passes the ValueObject’s new value to any connected callback function.

local Bool = Instance.new("BoolValue")

Bool.Changed:Connect(function(Value)
	print(Value) --this print occurs when the value is changed below
end)

Bool.Value = true
4 Likes

i dont understand why this only works in run mode and how to get it to work in play mode too

1 Like