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 11 years ago

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

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

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

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

2 answers

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
11 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-

01wait()
02local plr = Game:GetService("Players").LocalPlayer
03local mouse = plr:GetMouse()
04 
05mouse.KeyDown:connect(function(key)
06    print(plr.Name .. " pressed " .. key)
07    if key == "e" then
08        -- code
09    end
10end)
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 — 11y
Ad
Log in to vote
-1
Answered by 11 years ago
1mouse.KeyDown:connect(function(Key)
2    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 — 11y
0
I tried key 47, but it works only in studio, not online. and it's in a local script. Orlando777 315 — 11y

Answer this question