Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local LP = game:GetService("Players").LocalPlayer
- local UIS = game:GetService("UserInputService")
- local PlrGui = LP:WaitForChild("PlayerGui")
- local isChatting = false
- local typeStr = ""
- local isChatting = false
- local isShift = false
- local recentMessages = {}
- local enumToChar = {
- ["Tab"] = {" "};
- ["Space"] = {" "};
- ["Hash"] = {"#", "~"};
- ["Quote"] = {"'", "@"};
- ["Comma"] = {",", "<"};
- ["Minus"] = {"-", "_"};
- ["Period"] = {".", ">"};
- ["Slash"] = {"/", "?"};
- ["Zero"] = {"0", ")"};
- ["One"] = {"1", "!"};
- ["Two"] = {"2", "\""};
- ["Three"] = {"3", "£"};
- ["Four"] = {"4", "$"};
- ["Five"] = {"5", "%"};
- ["Six"] = {"6", "^"};
- ["Seven"] = {"7", "&"};
- ["Eight"] = {"8", "*"};
- ["Nine"] = {"9", "("};
- ["Semicolon"] = {";", ":"};
- ["Equals"] = {"=", "+"};
- ["LeftBracket"] = {"[", "{"};
- ["BackSlash"] = {"\\", "|"};
- ["RightBracket"] = {"]", "}"};
- ["Backquote"] = {"`"};
- }
- local realProcess = {
- [""] = true;
- ["Tab"] = true;
- ["`"] = true;
- }
- local function isBox(Obj, Msg)
- if Obj.ClassName == "TextBox" and Obj.Text == Msg then
- return true
- end
- for _,v in pairs(Obj:GetChildren()) do
- local childVal = isBox(v, Msg)
- if childVal then
- return true
- end
- end
- end
- UIS.InputEnded:connect(function(input, processed)
- input = input.KeyCode
- if input == Enum.KeyCode.LeftShift or input == Enum.KeyCode.RightShift then
- isShift = false
- end
- end)
- UIS.InputBegan:connect(function(input, processed)
- input = input.KeyCode
- if input == Enum.KeyCode.LeftShift or input == Enum.KeyCode.RightShift then
- isShift = true
- return
- end
- if not processed then
- isChatting = false
- typeStr = ""
- return
- end
- local key = tostring(input):sub(14)
- local keyReal = enumToChar[key] or (#key == 1 and {key:lower(), key}) or {""}
- keyReal = isShift and keyReal[2] or keyReal[1]
- if input == Enum.KeyCode.Backspace then
- typeStr = typeStr:sub(1, #typeStr-1)
- elseif #typeStr == 0 and isChatting == false and keyReal == "/" then
- isChatting = true
- else
- typeStr = typeStr .. keyReal
- end
- if input == Enum.KeyCode.Return then
- if isChatting and typeStr ~= "" then
- local lastMessage = typeStr
- typeStr = ""
- isChatting = false
- wait(1/30)
- local hasFound = false
- for _,v in pairs(recentMessages) do
- if v == lastMessage then
- hasFound = true
- break
- end
- end
- if not hasFound then
- print("Whisper:", lastMessage)
- end
- lastMessage = ""
- else
- typeStr = ""
- isChatting = false
- end
- elseif not isChatting and not realProcess[keyReal] and not tonumber(keyReal) then
- if not isBox(PlrGui, typeStr) then
- isChatting = true
- end
- end
- --print(key, keyReal, typeStr)
- end)
- LP.Chatted:connect(function(Msg)
- recentMessages[#recentMessages+1] = Msg
- wait(1)
- table.remove(recentMessages, 1)
- end)
Advertisement
Add Comment
Please, Sign In to add comment