:CaptureFocus() does not work

Hello everyone,

I am trying to make some sort of custom chat. A textbox, where the message should be typed in has been created already. I want the player to press a certain hotkey to be able to start typing in the textbox (kind of like Roblox’s “Press / to chat”).

I have tried using Roblox’s resources and implemented their code from this post:

Unfortunately this does not work, here is what the code looks like.

local ContextActionService = game:GetService("ContextActionService")
local ACTION_NAME = "FocusTheTextBox"
local textBox = script.Parent

local function handleAction(actionName, inputState, _inputObject)
	if actionName == ACTION_NAME and inputState == Enum.UserInputState.End then
		textBox:CaptureFocus()
	end
end

ContextActionService:BindAction(ACTION_NAME, handleAction, false, Enum.KeyCode.Q)

For reference here is where it is placed in:
https://i.gyazo.com/5af938039e82dfe058003ab08743d1d1.png

I do not know if this information might be helpful but I am using MacOS.

Thank you, I appreciate any help!

You should change this post’s topic to #help-and-feedback:scripting-support and you might get more responses.

My bad, I somehow fixed this issue though. Thank you!