I am not talking about BoolValues or any type of Value, only variables.
I want to know if it's possible to detect if a variable has been set to true/false, kind of like the Changed
event. But I recall trying to use the Changed
event on a variable before, and it didn't work. Just a quick question, any help appreciated.
Using plain Lua variables? No, there isn't. You probably used the .Changed event on a BoolValue without knowing.
You can, however, use Roblox built-in BoolValues, NumberValues, StringValues (and other values) in your scripts and listen to their .Changed events. This is a common practice:
local str = Instance.new("StringValue") val.Changed:Connect(function(newStr) print(newStr) end) str.Value = "Hello, World!"
BoolValue.Changed:connect(function(NewValue) print(NewValue) end)
http://wiki.roblox.com/index.php?title=API:Class/BoolValue/Changed