How can I check when all bools are activated?

Hello, in my game i am currently working on one of the main aspects is pushing buttons to progress, and whenever all buttons are pressed players have about a minute to get back to the elevator before it leaves

What i am trying to do here is constantly check if all buttons have been pressed with bool values so the game knows when to warn players that they have to get back to the elevator.

This is the code inside the button:

local buttonWav = script["button.wav"]
local buttonPress = script["Generator Button"]

local proxPrompt = script.Parent.ProximityPrompt

local light = script.Parent.PointLight
local button = script.Parent

local pressed = false
local debounce = true

button.ProximityPrompt.Triggered:Connect(function()
	
	if debounce then
		debounce = false
		
		if not pressed then
			
			buttonPress:Play()
			proxPrompt.Enabled = false
			wait(0.3)
			light.Color = Color3.new(0.266667, 1, 0)
			button.BrickColor = BrickColor.new("Lime green")
			buttonWav:Play()
			proxPrompt:Destroy()
			
		end
		
		pressed = true
		
	end
	
end)

again, i’m just trying to make a script that checks constantly if all buttons are pressed. Thank you in advance

Create a NumberValue and whenever it’s value changes, check if the value is greater than the total # of blocks.

And change the code inside the button to

if not pressed then
			            NumberValue.Value += 1

			buttonPress:Play()
			proxPrompt.Enabled = false
			wait(0.3)
			light.Color = Color3.new(0.266667, 1, 0)
			button.BrickColor = BrickColor.new("Lime green")
			buttonWav:Play()

			proxPrompt:Destroy()
			
		end

The server script checking:

NumberValue.Changed:Connect(function(property)
if property == "Value" then
if NumberValue.Value == #buttons then
--your code
       end
    end
end)

where should i put the number value? like, inside the script, the button or…

not inside the button because it eventually gets destroyed. Put it in ServerStorage or Workspace

NumberValue refers to the number value you created. You can change it to

game.Workspace.buttonsPressed

or whatever you like

alright, i’ll try this out, thank you!

1 Like

update: it worked! the number value successfully changes when a button is pressed, now i just need to add the elevator stuff

thank you so much!