Hi, I’m using ContextActionService. For my game I need to make a custom movement system. But I ran into a problem. When a player presses a key then goes into chat and releases the key it doesn’t get detected. Is there a way to detect it when a player is in chat and releases a key besides using UIS?
i dont think theres a way to detect if a player is in chat without using UIS.
heres an example of what i think might work
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if not gameProccessedEvent then
print("User is in chat")
--ur code goes here
end
end
1 Like
You can hook a function to UserInput’s “TextBoxFocused” RBXScriptSignal object (event) and use its parameter to determine if the default chat’s chat bar was focused.
local userInput = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local chatGui = playerGui:WaitForChild("Chat")
local chatBar = chatGui:FindFirstChild("ChatBar", true)
local function onTextBoxFocused(textBoxFocused)
if textBoxFocused == chatBar then
print("Hello world!")
end
end
userInput.TextBoxFocused:Connect(onTextBoxFocused)
https://developer.roblox.com/en-us/api-reference/event/UserInputService/TextBoxFocused
Similarly, you can use the “Focused” RBXScriptSignal object shared by all TextBox instances to identify when the default chat’s char bar is focused.
local players = game:GetService("Players")
local player = players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local chatGui = playerGui:WaitForChild("Chat")
local chatBar = chatGui:FindFirstChild("ChatBar", true)
local function onChatBarFocused()
print("Hello world!")
end
chatBar.Focused:Connect(onChatBarFocused)