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

Is there a way to tell if the player is currently chatting?

Asked by 8 years ago

So basically I want to know if there's a way to tell if the person is currently chatting, whether they started chatting by pressing "/" or if they clicked on the chat gui. Is there any way of telling whether a player is currently in the process of chatting?

Thanks.

0
Give me a few minutes, you might be able to use UserInputService's TextBoxFocused event. M39a9am3R 3210 — 8y
0
Idk how to, but try making an event where the Slash key is hit, again, not exactly foolproof, but a suggestion nonetheless. RadiantSolarium 35 — 8y

1 answer

Log in to vote
4
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
8 years ago

From some experimentation, I was able to make a script that would indicate if a player was typing in ROBLOX's CoreGui Chat. Due to the fact you can not receive the full hierarchy of the Chat Gui, I had to improvise with pcall. Pcall basically means protection call, it will run a function and return two values one being a bool to tell if it ran correctly or not, the other being a string that will report an error. That's why you may see local succ, err = pcall(function() end). I manipulated the script to indicate if a error would be given, if the function could not receive the hierarchy of the Gui object.

Without further ado, here is the script.

game:GetService('UserInputService').TextBoxFocused:connect(function(TextBox)
    local succ = pcall(function() TextBox:GetFullName() end)
    if not succ then print('User is typing.') end
end)

game:GetService('UserInputService').TextBoxFocusReleased:connect(function(TextBox)
    local succ = pcall(function() TextBox:GetFullName() end)
    if not succ then print('User quit typing.') end
end)

In the script, TextBoxFocused and TextBoxFocusReleased events provide a instance value, being the TextBox taking input. With utilization of the first value pcall provides, I was able to tell if the function was successful or not, getting the TextBox's hierarchy. So, if not successful then print user is typing, when a TextBox is being focused, and similar concept to TextBoxFocusReleased.


If you have any questions, feel free to comment below. If this answered your question, hit the accept answer button. If it just helped you, then press the upvote button.
0
Thanks! Quick question, would this work if the player was already chatting when the script which had these events in it started to run? TurboFusion 1821 — 8y
0
I do not believe so, and I do not believe there is a property to indicate it. M39a9am3R 3210 — 8y
0
Darn, this will do then. Thanks! TurboFusion 1821 — 8y
Ad

Answer this question