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

How would i add a hotkey to a custom chat GUI? (solved!)

"Click here or press "/" to chat!" I don't know how to set focus to the TextBox for the custom chat GUI i have created.

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(key)
if key == "/" then -- I even tried it with a simple key, to test to make sure the key wasn't the problem.
script.Parent.TypeHolder.TextBox.GotFocus = true
script.Parent.TypeHolder.TextBox:CaptureFocus()
end
end)

That's what i have so far, and it fails every time.

4 comments

0

What is this "GotFocus" property?

0

gotfocus lol

0

I was using the CoreScript for chats from ROBLOX: 'self.GotFocus = true' and 'self.ChatBar:CaptureFocus()'

0

If your question has been answered, please accept the answer that helped you solve your question.

1 answer

The "/" key is restricted to the KeyUp Event for some reason...Therefore, we just need to switch out the two events. Try this:

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()

Mouse.KeyUp:connect(function(key)
	if key == "/" then
		script.Parent.TypeHolder.TextBox:CaptureFocus()
	end
end)

Try this now. I believe everything in your script was correct besides what I fixed. Anyways, if you have any further problems or questions, please leave a comment below. Hope I helped :P

5 comments

0

Saddly, not even that worked :l I was using the CoreScript for chats from ROBLOX: 'self.GotFocus = true' and 'self.ChatBar:CaptureFocus()' So i dont even know how accurate the code is for this kind of thig.

0

All you need to do is remove the 'script.Parent.TypeHolder.TextBox.GotFocus = true' and it should work fine.

0

It worked! thanks so much :)

0

Max, there's an accept answer button on each answer, you should click it if it solved the question.

0

No prob, glad I could help.

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