Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a Custom Chatbar?

local ChatBar = script.Parent
game:GetService("UserInputService").InputBegan:connect(function(input,proc)
    if not proc and input.KeyCode == Enum.KeyCode.Slash then
if ChatBar.Transparency == .5 then
ChatBar.Transparency = .25

end
end
end)

How do I make it so that it will detect the next keys until enter is pressed? then insert them into the chat bar as text? Unless you guys know how to disable Roblox's chat commands like /w and stuff like that.

Note It's A local script, and Chatbar is a Textbook.

1 answer

✓ Accepted answer

Commonly for user created chat bars, the user would force focus on the textbox. To accomplish this, we can use the CaptureFocus() function. Once we have ran the function we can set up another connection line for FocusLost, which returns if Enter has been pressed.

local ChatBar = script.Parent
game:GetService("UserInputService").InputBegan:connect(function(input,proc)
    if not proc and input.KeyCode == Enum.KeyCode.Slash then
        if ChatBar.Transparency == .5 then
            ChatBar.Transparency = .25
            ChatBar:CaptureFocus()
        end
    end
end)
ChatBar.FocusLost:connect(function(enterPressed)
    if enterPressed then
        --Code to give ChatBar Text to server.
    end
end)

Once you start using a custom chat bar, you will have to make your own chat commands and alternate means of making Chatted Command scripts work (emotes, whispering, and team chatting will need to be set up by yourself).

If you have any questions, feel free to ask in the comments. If this answered your question then hit the accept answer button.

1 comment

0

Thanks. I didn't read this until I finished the script myself from help from Community Chat, but my script is pretty similar to this, except its more touch devices compatible. :)

This discussion is preserved as it was. New answers, comments, and votes are closed.