Advertisement
HudsonScripterRoblox

Tank Script

May 20th, 2019
942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. print('Running and used')
  2. -- Services
  3. local uis = game:GetService("UserInputService")
  4.  
  5. -- Variables
  6. local user
  7. local press --> for input connection towards the user
  8. local release --> for input connection towards the user
  9.  
  10. -- Tables
  11. local keys = {Enum.KeyCode.W, Enum.KeyCode.S, Enum.KeyCode.A, Enum.KeyCode.D}
  12.  
  13. -- Parts and RemoteEvents
  14. local tool = script.Parent
  15. local seat = script.Parent:WaitForChild("v_seat").Value
  16.  
  17.  
  18. local function equipped(UserMouse)
  19.     -- Start of User's Input
  20.     press = uis.InputBegan:Connect(function (push)
  21.         if push.KeyCode == Enum.KeyCode.W then
  22.             print('Forward β–²')
  23.             seat.front:FireServer(UserMouse)
  24.         elseif push.KeyCode == Enum.KeyCode.S then
  25.             print('Backward β–Ό')
  26.             seat.back:FireServer(UserMouse)
  27.         elseif push.KeyCode == Enum.KeyCode.A then
  28.             print('Turning Left <<')
  29.             seat.left:FireServer(UserMouse)
  30.         elseif push.KeyCode == Enum.KeyCode.D then
  31.             print('Turning Right >>')
  32.             seat.right:FireServer(UserMouse)
  33.         end
  34.     end) -- End of User's Input
  35.    
  36.     -- Stopping User's Input
  37.     release = uis.InputEnded:Connect(function (pull)
  38.         for _, v in pairs(keys) do
  39.             if pull.KeyCode == v then
  40.                
  41.             end
  42.         end
  43.     end) -- End of Stopping the input
  44. end
  45.  
  46. local function unequipped(UserMouse)
  47.     seat.stop:FireServer()
  48.     press:Disconnect()
  49.     release:Disconnect()
  50.     seat.stop:FireServer()
  51. end
  52.  
  53. tool.Equipped:Connect(equipped)
  54. tool.Unequipped:Connect(unequipped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement