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

Help with KeyDown?

Asked by 9 years ago

Can anyone tell me why this script won't work? Output show's no error's. I am trying to make a Custom-Chat GUI, But this KeyDown thing won't work.

01wait(1)
02 
03-- Variables
04local Player = game.Players.LocalPlayer
05local Mouse = Player:GetMouse()
06local Text = script.Parent.TextFrame.TextBox
07 
08-- Main Script
09Mouse.KeyDown:connect(function(key)
10    if key == Enum.KeyCode.Slash then
11        Text:CaptureFocus()
12    end
13end)

1 answer

Log in to vote
1
Answered by 9 years ago

Problem Roblox locks backslash as its used in their own functions this is able from this script below. Solution

01-- Variables
02local Player = game.Players.LocalPlayer
03repeat() wait until Player.Character
04local Mouse = Player:GetMouse()
05local Text = script.Parent.TextFrame.TextBox
06 
07-- Main Script
08game:GetService("UserInputService").InputBegan:connect(function(input)
09    if input.KeyCode == Enum.KeyCode.Slash then
10        Text:CaptureFocus()
11    end
12end
Ad

Answer this question