Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. seat = script.Parent
  2. power = seat.Parent.Parent.Control:GetChildren()
  3. eng = { }
  4.  
  5. function GetEngines()
  6. for _, wheels in pairs(seat.Parent.Parent.Control:GetChildren()) do
  7. if (wheels.Name == "Engine") then
  8. local bv = script.BodyVelocity:Clone()
  9. bv.Parent = wheels
  10. eng[#eng + 1] = wheels
  11. end
  12. end
  13. end
  14.  
  15. wait(3)
  16.  
  17. GetEngines() -- This is the function that lagged the hell out of the game when it was after the next few lines
  18.  
  19. while wait(0.1) do
  20. local maxspeed = seat.MaxSpeed
  21.  
  22. for _, a in pairs(eng) do
  23. a.BodyVelocity.Velocity = (maxspeed * (seat.Current.Value / 100)) * a.CFrame.lookVector
  24. end
  25.  
  26. if seat.Velocity.Magnitude < 0.5 and seat.Current.Value <= 0 then
  27. seat.Current.Value = 0
  28. for _, a in pairs(eng) do
  29. a.Anchored = true
  30. end
  31. else
  32. for _, a in pairs(eng) do
  33. a.Anchored = false
  34. end
  35. end
  36.  
  37. if seat.Current.Value > 100 then
  38. seat.Current.Value = 100
  39. end
  40.  
  41. if seat.Current.Value < -20 then
  42. seat.Current.Value = -20
  43. end
  44.  
  45. if seat.Velocity.Magnitude > maxspeed and seat.Current.Value > 0 then
  46. for _, a in pairs(eng) do
  47. a.BodyVelocity.Velocity = Vector3.new(0,0,0)
  48. end
  49. end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement