Multiple button is pressed at once

Can someone help me, i wanted to detect if 2 button is click at the same time like there are 2 buttons next to each other if the player click the 2 at the same time, it will print on the output showing an error

1 Like

Show the script + error output

1 Like

Something you could do is manage a couple of variables, giving the player a small window of time to click both.

local buttonOneClicked = false
local buttonTwoClicked = false
local buttonOne = --path to Button One here
local buttonTwo = --path to Button Two here

local function bothButtonsPressed()
    --what you want to happen if both are pressed
end

local function processOneClick()
    buttonOneClicked = true
    if buttonOneClicked and buttonTwoClicked then
        buttonOneClicked = false
        buttonTwoClicked = false
        bothButtonsPressed()
    end
    task.wait(0.25)
    buttonOneClicked = false
end

local function processTwoClick()
    buttonTwoClicked = true
    if buttonOneClicked and buttonTwoClicked then
        buttonOneClicked = false
        buttonTwoClicked = false
        bothButtonsPressed()
    end
    task.wait(0.25)
    buttonTwoClicked = false
end

buttonOne.MouseButton1Click:Connect(processOneClick)
buttonTwo.MouseButton1Click:Connect(processTwoClick)