I've tried to make this chat GUI, with a custom chat bar. As usual, the script works in Studio, but not in the client, and I was wondering if I would need to change it otherwise.

The script

local service = game:GetService("UserInputService")
local gui = script.Parent

service.InputBegan:connect(function(keyPressed,gameProcessedEvent)
    if gameProcessedEvent then 
        return  end
	if script.Parent.Parent.Status.Value == true then
    	if keyPressed.KeyCode == Enum.KeyCode.E then
    		   gui.TextBox:CaptureFocus()
    	end
	end
end)

6 comments

0

Is this a LocalScript?

0

Yeah

0

Tested it under the circumstances your code runs on, the only thing that could be wrong is if the rest of your code isn't passing the if statement, or if TextBox doesn't exist.

0

Otherwise it worked fine for me.

0

Huh. I guess I'll try something else then. Thanks anyway.

0

Make sure Status is true and in your PlayerGui. Otherwise, I see nothing wrong with it.