SHARE
TWEET

Untitled

a guest May 23rd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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();
  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' 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;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top