I have no idea why this line of code won't work. the following global script is inside of a Bool value that is inside of a local script.
while wait() do if script.Parent.Value == true then script.Parent.Parent.Disabled = true end end while wait() do if script.Parent.Value == false then script.Parent.Parent.Disabled = false end end
the goal as you can see is when the parent of this script (the boolvalue) is set to true to disable the local script which is the parent of the bool value and when the value of the bool is false to undisable the local script it.
You should use Changed
event instead of a while loop
script.Parent.Changed:Connect(function(val) script.Parent.Parent.Disabled = val end)
As for why it doesn't work, it could be because the Disabled
property doesn't "fully" disable the script. You should rather make the localscript check if the boolvalue's value is true
, and if so, abort all actions it's doing, like this:
local bool = script.BoolValue --an event example: plr.CharacterAdded:Connect(function(char) if bool.Value then return end --normal code end)
Instead of doing 2 different Loops just use a conditional statement.
while wait() do if script.Parent.Value == true then script.Parent.Parent.Disabled = true elseif script.Parent.Value == false then script.Parent.Parent.Disabled = false end
Your' second loop was never able to execute.
while wait() do if script.Parent.Value == true then script.Parent.Parent.Disabled = true elseif script.Parent.Value == false then script.Parent.Parent.Disabled = false end end
hi your welcome