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

How to make an Changed event to a BoolValue?

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

1 comment

0

Parent the instance to something?

3 answers

✓ Accepted answer

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

2 comments

0

no, it changes by a script

0

Huh weird, Can you post both script? the one with .Changed and the one that changes the value

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)

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