Hello,
I’ve been working on a system similar to roblox chat where when you press / it selects a textbox. However, It types the / into the text box as well as focusing. This only occurs on roblox client and does not happen on studio for some odd reason.
local uis = game:GetService("UserInputService")
local msgBox = gui.MessageBox
-- ...
uis.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.Slash then
msgBox:CaptureFocus()
msgBox.Text = ""
end
end)
I have tried using task.wait() and task.defer, however, it did not yield any different results, and I don’t want any delays just like the native chat box would not have any extra delay.
yes it says / on the client. It is actually inputted into the textbox. When i print the contents of the texbox, it confirms the slash is there. Also, when i send it to the server it has the /. I don’t see how changing it on the server would work when it’s a playergui component. Especially since the input is all handled inside a local script.
you can try doing a variable called firsttype and make it true and do ui.Focus:Connect() and then make the first variable called firsttype true and do another one that when ui.FocusLost:Connect() and if the string == “” then firsttype = false. for what happens when ui.Focus if the firsttype == false then string == “”. I hope this works but I currently have no way to prove it because im going to be honest im horrible at gui… Especially when it comes towards handling stuff between client and server side.
If you want me to clarify you can ask but again, I have no way of proving it works or not and im just naming solutions that have a 10% chance at most working