Hey. I’m making an index for my game and I am making a TextLabel that will say how many out of 180 has been discovered.
What I’ve Tried
I’ve tried using a for loop, it works but it will keep adding so it will make it say something like 1234/180 and that is not what I am trying to do.
I have also tried using a debounce to make it wait like 5 seconds but it just keeps adding after 5 seconds even when the player doesnt have that much discovered.
The reason I tried for loops is because I want it to update as soon as the player discovers one. What I want is the table will count how many BoolValues are true and then print.
Local ValuesThatAreTrue = 0
Local Childs = game.Workspace:GetChildren()
for Index, ValueToCheck in pairs(Childs) do
if ValueToCheck.Value == true then
ValuesThatAreTrue = ValuesThatAreTrue + 1
end
end
Label.Text = ValuesThatAreTrue.."/"..#Childs
I am on phone so sorry if somthing is mis spelled.
While true do
Local ValuesThatAreTrue = 0
Local Childs = game.Workspace:GetChildren()
for Index, ValueToCheck in pairs(Childs) do
if ValueToCheck.Value == true then
ValuesThatAreTrue = ValuesThatAreTrue + 1
end
end
Label.Text = ValuesThatAreTrue.."/"..#Childs
wait(5)
end