So I need to make a BoolValue have a changed event and using InOut.Changed
never fired.
I was guided to use this
local inOut = Instance.new("BoolValue") inOut:GetAttributeChangedSignal("Value"):Connect(function(Change) print("Change:", Change) end)
but now i get this error:
Attributes are not currently enabled
The reason that the event is not firing is because there is no physical value yet. While you have created a BoolValue
, you have not put it anywhere. All you need to do to fix this code is change the parent of the value. This change would make your code look like this:
local inOut = Instance.new("BoolValue") inOut.Parent = workspace inOut:GetAttributeChangedSignal("Value"):Connect(function(Change) print("Change:", Change) end)
Bool = Instance.new("BoolValue") Bool.Parent = workspace Bool.Changed:Connect(function(Prop) print ("Changed : ".. tostring(Prop)) end)
.Changed Fires for me?
Did you perhaps changed the value via the explorer in roblox studio? it won't fire that way
The .Changed function doesn't work when checking for the value within an object working
Proper usage would look something like this:
local randomInt = game.Workspace.IntValue -- not game.Workspace.IntValue.Value randomInt.Changed:connect(function() if randomInt.Value >= 5 then print("do stuff") end end)