#InputService

12 messages · Page 1 of 1 (latest)

boreal badger
#
local player = game.Players.LocalPlayer
local remote = player.Character:FindFirstChild("Invisibility").Inv
local ui = script.Parent.Parent
local uis = game:GetService("UserInputService")

game:GetService("UserInputService").InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E and ui.Parent == player.PlayerGui then
        print("keycode")
        remote:FireServer(player)
        
    end



end)

how do i make it not count when the player is writing in the chat?

fiery cargo
#

hi i will be your assistance for today

#

local player = game.Players.LocalPlayer
local remote = player.Character:FindFirstChild("Invisibility").Inv
local ui = script.Parent.Parent
local uis = game:GetService("UserInputService")

game:GetService("UserInputService").InputBegan:Connect(function(input)
-- Check if the input is the "E" key and the player is not typing in the chat
if input.KeyCode == Enum.KeyCode.E and not uis:GetFocusedTextBox() then
print("E key pressed")
-- Check if the UI is currently parented to the player's PlayerGui
if ui.Parent == player.PlayerGui then
-- Check if the remote event exists
if remote then
remote:FireServer(player)
else
warn("Remote event 'Inv' not found")
end
end
end
end)

tawny spokeBOT
#

studio** You are now Level 7! **studio

fiery cargo
#

@boreal badger

boreal badger
#

alr i'll try that

#

it works, thx

fiery cargo
#

np

potent lodge
# boreal badger it works, thx

yo. theres an another way to do it.

UIS.InputBegan:Connect(function(input, processed)
if processed then return end

--do things

end)```


example:
Player could do something pressing E. if player types letter "E" in the chat, or something containing it, we'd want to ignore that. 

the gameprocessed event allows us to ignore situations such that and other cases.
#

or you could also do

uis.InputBegan:Connect(function(input,processed)

if input.KeyCode == Enum.KeyCode.E and not processed

end)```
#

same thing

#

this is a better way because it will also handle other cases you want to ignore