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

How to make it not run a script if user is typing (UserInputService) ?

Asked by 6 years ago

i have a script that if i press a key it makes everything invisible it works but if im typing and i press the key while typing it would work too, how do i stop it when im typing?

this is what im using

game:GetService("UserInputService").InputBegan:connect(function (input)
if input.UserInputType==Enum.UserInputType.Keyboard and input.KeyCode==Enum.KeyCode.X then

--CODE

end
end)

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

InputBegan gives a second argument which you can use to determine if the user is typing or not:

game:GetService("UserInputService").InputBegan:Connect(function(input,isTyping)
if input.UserInputType==Enum.UserInputType.Keyboard and input.KeyCode==Enum.KeyCode.X and isTyping == false then
--CODE
end
end)
0
thank you very much LIGHTBOMBS 4 — 6y
Ad

Answer this question