Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

InputBegan stops when mouse button is clicked help?

Asked by 8 years ago
Extra = false

function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.LeftControl then
        Extra = true
    end
end

function onKeyStopped()
    Extra = false
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)
game:GetService("UserInputService").InputEnded:connect(onKeyStopped)
Why does Extra go back to equaling false if the mouse is clicked? Is they're a way to make it equal true even though someone clicks the mouse?

1 answer

Log in to vote
1
Answered by 8 years ago

This is because you did not specify what key had to end in order to set extra to false, so any input that ends will set it to false. If this is true, try holding the key, and push another key (do not hold down). If the code is the same, Extra should become false. You can either create a specifier to this (basically copy-paste onKeyPress (with some obvious alterations) or you could ContextActionService.

Ad

Answer this question