Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

InputBegan stops when mouse button is clicked help?

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

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.