I want to enable a feature where typing in the chat triggers the sound of keyboard keys.
2 - Issue:
I can’t locate the Chat GUI element to correctly use the Focused method on the ChatTextBox.
3 - Solutions Attempted:
I’ve explored various solutions but haven’t been able to find one that works.
Code:
local ChatTextBox: TextBox = game.Players.LocalPlayer.PlayerGui:WaitForChild("Chat").Frame.ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar.Text
local TypingEnabled: boolean = false
ChatTextBox.Focused:Connect(function()
TypingEnabled = true
end)
ChatTextBox.FocusLost:Connect(function()
TypingEnabled = false
end)
Issue Encountered:
Running this code results in the following error:
14:51:00.913 Infinite yield possible on 'Players.AB_MAIN.PlayerGui:WaitForChild("Chat")' - Studio
14:51:00.913 Stack Begin - Studio
14:51:00.913 Script 'Players.AB_MAIN.PlayerGui.CambiarColor', Line 1 - Studio - CambiarColor:1
14:51:00.913 Stack End - Studio
You could use this, but this also applies to all TextBoxes in your game:
--LocalScript in StarterPlayerScripts
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.TextInput and processed then
--play sound
end
end)