I was wondering how if I can make this script check every value, if it the value of each BoolValue is true then to return false. But I'm not exactly sure how to. Can anyone help?
gather = workspace.Model1:GetChildren() for i = 1,#gather do if gather[i].Value == true then return false end end
You have the right cocept, just you're using the return
statement inproperly.
The return statement is a statment that should be used in a function. It makes whatever function you used the statement on return the given argument, and also discontinues the function. Example;
function add(a,b) return a + b print('lol') --This won't print end print(add(1,3)) --> 4
But that's besides the point. Instead of returning false, set the value to false.
local gather = workspace.Model1:GetChildren() for i = 1,#gather do if gather[i].Value == true then gather[i].Value = false end end
Additional changes - you can use a generic for with the Pairs function.. which is actually meant to iterate through tables.. also you can 'toggle' the value by doing value = not value
.
local gather = workspace.Model1:GetChildren() for i,v in pairs(gather) do v.Value = not v.Value end --And if you don't want to toggle it then just return it to the old syntax(: for i,v in pairs(gather) do if v.Value then v.Value = false end end