Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make an Changed event to a BoolValue?

Asked by 4 years ago

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

0
Parent the instance to something? Azure_Kite 885 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

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)
Ad
Log in to vote
0
Answered by 4 years ago
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

0
no, it changes by a script plzdonthitman 3 — 4y
0
Huh weird, Can you post both script? the one with .Changed and the one that changes the value Azure_Kite 885 — 4y
Log in to vote
0
Answered by
Robowon1 323 Moderation Voter
4 years ago

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)

Answer this question