Advertisement
Guest User

Code

a guest
Jan 18th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | None | 0 0
  1. local seat = game.Workspace.VehicleSeat
  2. local part = game.Workspace.Part
  3. local bodyGyro = game.Workspace.Part.BodyGyro
  4. local bodyVelocity = game.Workspace.Part.BodyVelocity
  5.         local RunService = game:GetService('RunService')
  6.  
  7. seat:GetPropertyChangedSignal("Occupant"):Connect(function(hum)
  8.     if game.Players:GetPlayerFromCharacter(seat.Occupant.Parent) then
  9.         local plr = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
  10.         local currentAngle = 0
  11.        
  12.         local rs = RunService.RenderStepped:Connect(function(step)
  13.                bodyVelocity.Velocity = (part.CFrame.LookVector  * 10)
  14.         end)    
  15.        
  16.         seat:GetPropertyChangedSignal("Throttle"):Connect(function(throttle)
  17.             if throttle == 1 then
  18.                 print("Increase throttle")
  19.             elseif throttle == 0 then
  20.                 print("Do nothing to throttle")
  21.             elseif throttle == -1 then
  22.                 print("Decrease throttle")
  23.             end
  24.         end)
  25.            
  26.         seat:GetPropertyChangedSignal("Steer"):Connect(function(steer)
  27.             if seat.Steer == -1 then
  28.                 print("Angle +1")
  29.                 repeat wait(.05)
  30.                     currentAngle = currentAngle + 4
  31.                      bodyGyro.CFrame =  CFrame.Angles(math.rad(0), math.rad(currentAngle), math.rad(0))
  32.                 until seat.Steer ~= -1
  33.             elseif seat.Steer == 0 then
  34.                 print("Do nothing to angle")                      
  35.             elseif seat.Steer == 1 then
  36.                 print("Angle -1")
  37.                 repeat wait(.05)
  38.                     currentAngle = currentAngle - 4
  39.                     bodyGyro.CFrame =  CFrame.Angles(math.rad(0), math.rad(currentAngle), math.rad(0))
  40.                 until seat.Steer ~= 1
  41.             end
  42.             print(currentAngle)
  43.         end)
  44.     end
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement