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:
Try http://wiki.roblox.com/index.php?title=Custom_chat_GUI That is the official guide on roblox wiki.
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!