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

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

Asked by 9 years ago

"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.

0
What is this "GotFocus" property? NotsoPenguin 705 — 9y
0
gotfocus lol unmiss 337 — 9y
0
I was using the CoreScript for chats from ROBLOX: 'self.GotFocus = true' and 'self.ChatBar:CaptureFocus()' max2461 0 — 9y
0
If your question has been answered, please accept the answer that helped you solve your question. FearMeIAmLag 1161 — 9y

1 answer

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

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

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. max2461 0 — 9y
0
All you need to do is remove the 'script.Parent.TypeHolder.TextBox.GotFocus = true' and it should work fine. dyler3 1510 — 9y
0
It worked! thanks so much :) max2461 0 — 9y
0
Max, there's an accept answer button on each answer, you should click it if it solved the question. drew1017 330 — 9y
0
No prob, glad I could help. dyler3 1510 — 9y
Ad

Answer this question