I have code for when a player presses a key, it prints something out. But the problem is, I don’t want it to print it out if the player presses the key in the chat.
Code:
local UserInputService = game:GetService("UserInputService")
local function onInputBegan(input, _gameProcessed)
if input.KeyCode == Enum.KeyCode.P then
print("The P button has been pressed!")
end
end
UserInputService.InputBegan:Connect(onInputBegan)
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local function onInputBegan(input, _gameProcessed)
if not _gameProcessed then
print("Player is typing")
else
if input.KeyCode == Enum.KeyCode.P then
print("The P button has been pressed!")
end
end
end
It breaks the whole script and never prints out anything anyways.
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local function onInputBegan(input, _gameProcessed)
if _gameProcessed then
print("Player is typing")
elseif input.KeyCode == Enum.KeyCode.P then
print("The P button has been pressed!")
end
end
Edit: Do i add a remote event then connect it and fire whenever the player presses the button? and there will be a localscript in playerscripts or whatever that prints out the message?
local UserInputService = game:GetService("UserInputService")
local function onInputBegan(input, _gameProcessed)
if _gameProcessed then
print("Player is typing")
elseif input.KeyCode == Enum.KeyCode.P then
print("The P button has been pressed!")
end
end
UserInputService.InputBegan:Connect(onInputBegan)