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

How do I add this special character to user input?

Asked by 10 years ago

I found this in a script but don't know what to replace instead of "GuiService"

--      -- CHatHotKey is '/'
--      GuiService:AddSpecialKey(Enum.SpecialKey.ChatHotkey)
--      GuiService.SpecialKeyPressed:connect(function(key) 
--          if key == Enum.SpecialKey.ChatHotkey then 

So I want to add that "/" character instead of this:

mouse.KeyDown:connect(function (key) -- Run function
    if key == "e" then

2 answers

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

GuiService is inaccessible to scripts created by users. If you're trying to detect keyboard input, I'd put a LocalScript inside of StarterGui with this code-

wait()
local plr = Game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()

mouse.KeyDown:connect(function(key)
    print(plr.Name .. " pressed " .. key)
    if key == "e" then
        -- code
    end
end)
0
I dont think I made my questions clear. I know how to type all that, but how do I replace "E" with "/". As stupid as that sounds if I just put "/" it wont work. Orlando777 315 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago
mouse.KeyDown:connect(function(Key)
    if key:byte() == 37 then -- 37 is the number code for "/"

You can find more number codes here: http://wiki.roblox.com/index.php/Taking_keyboard_input

0
37 is for F12... Orlando777 315 — 10y
0
I tried key 47, but it works only in studio, not online. and it's in a local script. Orlando777 315 — 10y

Answer this question