I found this chunk of code in a script
-- -- 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 "e". As stupid as that sounds just replacing "/" for E wont work.
[MOUSE AND PLAYER ALREADY DEFINED]
--(Not the whole script, just 2 lines of it) mouse.KeyDown:connect(function (key) -- Run function if key == "e" then
I tried this:
[MOUSE AND PLAYER ALREADY DEFINED]
--(Not the whole script, just 2 lines of it) mouse.KeyDown:connect(function(Key) if key:byte() == 47 then -- 47 is the number code for "/"
But it only works in studio, not online. And yes, it's in a local script.
The problem is that you never defined mouse. In a local script in startergui, it should be sorted as this:
local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() mouse.KeyDown:connect(function (key) local key = key:lower() if key == "e" then --do stuff end end)
If you would like to use "/", I recommend to use userinputservice instead.
wheres the
local Player = game.Players.LocalPlayer?