Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Chatbar is not capturing focus. Why!? Everything seems right.

Asked by 7 years ago
Edited 7 years ago

I seem to have everything down to the 'T' yet it is still not capturing focus of my keyboard but it's telling me on F9 that it's running!?

What gives? It should be as simple as the a, b, c's!

local StarterGui = game:GetService("StarterGui")
local Chat = game.StarterGui:WaitForChild("Chatbar");
local Input = Chat.Chatbar.Input;

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        print("The button / was pressed.");
        Input:CaptureFocus();
        print(Input:IsFocused());
    end
end

game.ContextActionService:BindAction("keyPress/", onKeyPress, false, "/");

I've included a free model to show you it in it's full form:

Here it is (the free model)

2 answers

Log in to vote
1
Answered by 7 years ago

Try http://wiki.roblox.com/index.php?title=Custom_chat_GUI That is the official guide on roblox wiki.

0
Thanks for the help, not really the answer that I wanted though. But still, thanks. Arithmeticity 167 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

You defined Chat as the ChatBar (TextBox), not Input. Plus, only TextBox objects can respond in :CaptureFocus().

Here. Let me fix the script for you!

local StarterGui = game:GetService("StarterGui")
local Chat = game.StarterGui:WaitForChild("Chatbar");
local Input = Chat.Chatbar.Input;

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        print("The button / was pressed.");
        Chat:CaptureFocus(); -- It should be Chat, not Input.
        print(Input:IsFocused());
    end
end

game.ContextActionService:BindAction("keyPress/", onKeyPress, false, "/");

Any questions? Leave a comment below, please. Thanks and I hope this will help you!

Answer this question