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.
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.
Do you get any output in the console?
attempt to index boolean with ‘Changed’
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’:
And then change the value of the BoolValue in the explorer.
Can you show us your tree in the explorer?
That wouldn’t work because I need it to be local.
Then do it with :GetPropertyChangedSignal("Value")
because else it doesn’t work in a LocalScript.
Use this instead, using changed isn’t as promising as GetPropertyChangedSignal.
script.Parent.BoolValue:GetPropertyChangedSignal("Value"):Connect(function()
print("Changed")
end)
Who told you that? Whoever did lied to you big time. You can use changed events in a local script.
Why not, there is no difference in their functionality
Yes however, changing to GetPropertyChangedSignal has worked for me better in recent times. I’m not sure why, but it just does.
Scripting Master Ching Cheng Pie.
No, try it yourself, it won’t work.
For BoolValue, :GetPropertyChanngedSignal() doesn’t need to be used as the .BoolValue.Changed event returns the Value by default.
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 )
Yep, this doesn’t only go for BoolValues but anything ending in value (ex IntValue)
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.
Actually it was probably cause he didn’t put NewValue inside of the ().
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)
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
i dont understand why this only works in run mode and how to get it to work in play mode too