Advertisement
Meliodas0_0

Untitled

Jul 7th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. local binds = {}
  2. local binds_first = {}
  3. local forcebinds = {}
  4. local uis = game:GetService'UserInputService';
  5.  
  6. function bind(key, func)
  7. binds[key] = func;
  8. end
  9. function bind_first(key, func)
  10. binds_first[key] = func;
  11. end
  12. function forcebind(key, func)
  13. forcebinds[key] = func;
  14. end
  15. function unbind(key)
  16. binds[key] = nil;
  17. binds_first[key] = nil;
  18. end
  19.  
  20. uis.InputBegan:Connect(function(key)
  21. key = key.KeyCode.Name:lower();
  22. local inChat = uis:GetFocusedTextBox() and true or false;
  23. if not inChat then
  24. if binds_first[key] and typeof(binds_first[key]) == 'function' then
  25. binds_first[key]();
  26. end
  27. end
  28. end)
  29.  
  30. uis.InputEnded:Connect(function(input)
  31. key = input.KeyCode.Name:lower();
  32. local inChat = uis:GetFocusedTextBox();
  33. if not inChat then
  34. if binds[key] and typeof(binds[key]) == 'function' and input.UserInputType.Name == 'Keyboard' then
  35. binds[key]();
  36. end
  37. if input.UserInputType.Name == 'MouseButton1' and binds.mouse1 ~= nil then
  38. binds.mouse1();
  39. end
  40. if input.UserInputType.Name == 'MouseButton2' and binds.mouse2 ~= nil then
  41. binds.mouse2();
  42. end
  43. else
  44. if forcebinds[key] and typeof(binds[key]) == 'function' then
  45. forcebinds[key]();
  46. end
  47. end
  48. end)
  49.  
  50. getgenv().bind = bind;
  51. getgenv().bind_first = bind_first;
  52. getgenv().forcebind = forcebind;
  53. getgenv().unbind = unbind;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement