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

Help with KeyDown?

Asked by 8 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.

wait(1)

-- Variables
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Text = script.Parent.TextFrame.TextBox

-- Main Script
Mouse.KeyDown:connect(function(key)
    if key == Enum.KeyCode.Slash then
        Text:CaptureFocus()
    end
end)

1 answer

Log in to vote
1
Answered by 8 years ago

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

-- Variables
local Player = game.Players.LocalPlayer
repeat() wait until Player.Character
local Mouse = Player:GetMouse()
local Text = script.Parent.TextFrame.TextBox

-- Main Script
game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.Slash then
        Text:CaptureFocus()
    end
end

Ad

Answer this question