In my last question, which BlueTaslem answered it, I wanted to disable a Local-Script. He said I should use a bool-value. That's my question. I want to disable a Local-Script, that's the only choice I have, if I change it's parent, it's gonna bug out.
How would I disable an object using a bool-value?
3 answers
A boolean value is basically the check-box you see in properties, with the indicator "check" mark yields true (and the absence of a "check" mark yields false). In a LocalScript, there are two boolean values:
Archivable Value (false = LocalScript won't be copied/cloned, and access to it is going to return nil)
Disabled Value (false = LocalScript will execute its code)
In your case, set the boolean value for the "Disabled" property as "true" (check mark it).
Ta-da! Your LocalScript is now disabled.
But if you want to use a BoolValue (which, in my opinion, is useless since there's one already in the object), you'll have to do something along the lines of this:
script.Parent.BoolValue.Changed:connect(function ()
if script.Parent.BoolValue == true then
script.Parent.LocalScript.Disabled = true
else
script.parent.LocalScript.Disabled = false
end
end)
You can make your own boolean values in your script like this (using LocalScript's property itself):
IsTrue = false
script.Parent.ClickDetector.MouseClick:connect(function ()
if IsTrue == false then
IsTrue = true
script.Parent.LocalScript.Disabled = true
else
IsTrue = false
script.Parent.LocalScript.Disabled = false
end
end)
Working script while using a BoolValue:
script.Parent.IsTrue.Value = false
script.Parent.ClickDetector.MouseClick:connect(function ()
if script.Parent.IsTrue.Value == false then
script.Parent.IsTrue.Value = true
else
script.Parent.IsTrue.Value = false
end
end)
script.Parent.IsTrue.Changed:connect(function ()
if script.Parent.IsTrue.Value == false then
script.Parent.LocalScript.Disabled = false
else
script.Parent.LocalScript.Disabled = true
end
end)
Schematic
Part (Object) > ClickDetector (Object)
IsTrue (Value Object)
Script (Object; where the aforementioned code is at)
LocalScript (Object)
I don't know what you script is doing, but the basis of it works like this:
local boolValue = script.Parent.Enab --This is the BoolValue, obviously
function someFunction()
if not Enab.Value then return end
--code, will not run if 'Enab's Value is set to `false`
end
Alternatively, if you're not using a function, you can remove that not and put the code you want to disable inside of the if statement:
local boolValue = script.Parent.Enab
if Enab.Value then
--code, will not ruin is 'Enab's Value is set to `false`
end
I think you can do this but i'm not sure:
local disablevalue = game.Workspace.disablevalue -- the name of the boolvalue
if disablevalue.Value == true then
script.Parent.Disabled = true -- the localscript is the script's parent
else then
script.Parent.Disabled = false
end
I think it will work, but i'm not certain.
This discussion is preserved as it was. New answers, comments, and votes are closed.

5 comments
Aw, a downvote. :( Why?
Overcomplicated, honestly. This question has a simple answer, no need to draw it out so much.
Ah, woops. xD Thanks for the advice.
Adark, it doesn't kill to explain everything. Some people want a thorough answer, others want a short and sweet one.
Great answer though, dude. You gave a very thorough explanation that would help anyone who's new to BoolValues. Upvote!