game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.R then
print("R was pressed")
if not game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,5816190) and player.Name~="Player1" and player.UserId~="20977517" and player.UserId~="166100685" and HasBall() then
game:GetService("MarketplaceService"):PromptGamePassPurchase(player,5816190)
else
jersey = player.Character:FindFirstChild("Jersey") or player.Character:FindFirstChild("NOPE")
if highlight == false and player.Character:findFirstChild("Football") and player.Character.Football:IsA("Tool")then
hstick:FireServer(jersey)
highlight = true
local gui = player.PlayerGui:FindFirstChild("Huff")
gui.TextLabel.Text = "Not ready"
for slimmy = 15,0,-1 do
wait(1)
gui.TextLabel.Text = ("Ready in "..slimmy)
end
highlight = false
gui.TextLabel.Text = "Ready"
end
end
end
end)
How would I make it so when u press "R" while typing in chat it wont trigger my gamepass?
2 answers
LocalScript
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
local keyPressed = input.KeyCode
print("A key has been released! Key:",input.KeyCode)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("The left mouse button has been released at",input.Position)
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
print("The right mouse button has been released at",input.Position)
elseif input.UserInputType == Enum.UserInputType.Touch then
print("A touchscreen input has been released at",input.Position)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
print("A button has been released on a gamepad! Button:",input.KeyCode)
end
if gameProcessed then
print("\tThe game engine internally observed this input!")
else
print("\tThe game engine did not internally observe this input!")
end
end)
This script was copied from the wiki, yes, I copied it.
However, notice the gameProcessed in the function. Then the part where it checks if gameProcessed is true[line 15], whenever the player presses on a button(binded by UserInputService) that means that the player actually pressed that button and isn't interacting on a GUI object such as chat, textboxes etc.
Hey there!
The second parameter passed in InputBegan and InputEnded is gameProcessed. If gameProcessed is true, this means the game engine has used the key for something (like chat) already. In your code, you would just have to add an if/then clause to check if gameProcessed is true. If it is true, then you would return. Here's an example below...
local UserInputService = game:GetService("UserInputService")
UserInputService.InputEnded:Connect (function(input, gameProcessed)
if gameProcessed then return end -- This is where we check!
if input.KeyCode == Enum.KeyCode.R then
print("Hey, you're not in chat!")
end
end)
Just leave a comment if this isn't exactly what you want or you're having any trouble.
If this was helpful remember to accept and upvote the answer.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
So basically all I have to do in my script is if inputObject.KeyCode == Enum.KeyCode.R then and not gameProcessedEvent