heya! I’m trying to create a custom text that is on the side of the screen and I don’t quite know how to script it so that it checks if he is focused and presses enter rather than pressing enter/return unfocused.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local chatInput = script.Parent.ChatInput
local chatRemoteEvent = ReplicatedStorage:WaitForChild("Events_"):WaitForChild("ChatRemoteEvent")
local function onEnterPressed(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Return and not gameProcessedEvent then
if chatInput.Text ~= "" then
chatRemoteEvent:FireServer(chatInput.Text)
chatInput.Text = ""
end
end
end
chatInput.Focused:Connect(function()
game:GetService("UserInputService").InputBegan:Connect(onEnterPressed)
end)