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
I’ll rewrite your script, which is the easiest to solve this issue.
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)
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)
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)
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)
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.