Boolvalue.changed function not working

bool = script.Parent

bool.Changed:Connect(function()

print("changed")

if bool.Value == true then

script.Parent.Text = "Build: On"

else

script.Parent.Text = "Build: Off"

end

end)

the local script above is supposed to change the text of the gui, or atleast print “changed” when the bool value is changed. but the script isn’t doing that. also, both the script changing the bool value, and the one checking if it has changed are local scripts

Hi there!

I’ll rewrite your script, which is the easiest to solve this issue. :wink:

local bool = script.Parent
local textlabel = ? --enter the location from the textlabel here. Seems like you didn't do that right in the other script, as you say the textlabel is the parent, but it looks like the boolvalue is the parent from the script. You gotta figure that out. ;-)

bool.Changed:Connect(function()
     if bool.Value then -- When the value is true.
          textlabel.Text = "Build: On"
     else
          textlabel.Text = "Build: Off"
     end
end)

Let me know if it worked! :slight_smile:

Kind regards,
Jonas

thanks for making my upgrading my script, and i did forget to add an extra parent for the location of the textlabel, the problem isnt fixed, the text wont change, nor will the script print “change when the script changes”

local bool = script.Parent

local textlabel = script.Parent.Parent

bool.Changed:Connect(function()

print("changed")

if bool.Value then 

textlabel.Text = "Build: On"

else

textlabel.Text = "Build: Off"

end

end)
1 Like

Hm, that’s quite weird. Do you have Discord? It’s easier to have a chat there and solve the issue. :wink:

marketmanager1#9316

Kind regards,
Jonas

ok i sent you a friend request

Accepted, message me. :wink: Cya there!

Mind if you add me too?

Operatik#8737

I need to find some extra details and it might be a hassle posting them here.

sure i can add you aswell hold on

Try using GetPropertyChangedSignal instead of just Changed.

local bool = script.Parent
local textlabel = --route to textlabel

bool:GetPropertyChangedSignal("Value"):Connect(function()
     if bool.Value then -- When the value is true.
          textlabel.Text = "Build: On"
     else
          textlabel.Text = "Build: Off"
     end
end)
1 Like

Do check your console. From what I understand from this piece of code, your LocalScript is inside a BoolValue object. BoolValue objects do not have a Text property.


The ultimate piece of code to trump all replies.

local Bool = script.Parent -- Why is your LocalScript inside the bool?
local TextLabel = somewhereThatIsntTheParent

-- Don't reinvent the wheel with GetPropertyChangedSignal. ValueObjects have a
-- specialised version of the Changed RBXScriptSignal, if I recall correctly.
-- In either case, there's no point changing it. It doesn't solve the problem.
Bool.Changed:Connect(function (Bool)
    TextLabel.Text = string.format("Build: %s", Bool == true and "On" or "Off")
end)
1 Like

As I understand it, it is doing nothing? Can you confirm that the script is running?
I know it may be an obvious thing to check, but it is worth noting.