Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.68 KB | None | 0 0
  1. local cf = CFrame.new
  2. local v3 = Vector3.new
  3. local cfA = CFrame.Angles
  4. local rad = math.rad
  5.  
  6. local Speed = 1 -- YOUR MOVEMENT SPEED HERE
  7. local TurningSpeed = .5 -- HOW FAST WILL THE HANDLING BE?
  8.  
  9. local Movement = {}
  10.       Movement.Forward = false
  11.       Movement.Right = false   
  12.       Movement.Left = false
  13.  
  14. local player = game.Players.LocalPlayer
  15. local sp = script.Parent
  16. local mouse = player:GetMouse()
  17.  
  18. function CFrameFromTopBack(at, top, back)
  19.     local right = top:Cross(back)
  20.     return cf(at.x,at.y,at.z,
  21.         right.x,top.x,back.x,
  22.         right.y,top.y,back.y,
  23.         right.z,top.z,back.z)
  24. end
  25.  
  26. function tweenCF(startCF,endCF,Step)
  27.     local startTop = (startCF*cfA(rad(90),0,0)).lookVector
  28.     local startBack = startCF.lookVector*-1
  29.     local endTop = (endCF*cfA(rad(90),0,0)).lookVector
  30.     local endBack = endCF.lookVector*-1
  31.     local startPos = startCF.p
  32.     local endPos = endCF.p
  33.     local newCF = CFrameFromTopBack(startPos:lerp(endPos,Step),startTop:lerp(endTop,Step),startBack:lerp(endBack,Step))
  34.     return newCF
  35. end
  36.  
  37. Movement.ForwardOn = function()
  38.     Movement.Forward = true    
  39. end
  40.  
  41. Movement.ForwardOff = function()
  42.     Movement.Forward = false       
  43. end
  44.  
  45. Movement.LeftOn = function()
  46.     Movement.Left = true   
  47. end
  48.  
  49. Movement.LeftOff = function()
  50.     Movement.Left = false  
  51. end
  52.  
  53. Movement.RightOn = function()
  54.     Movement.Right = true  
  55. end
  56.  
  57. Movement.RightOff = function()
  58.     Movement.Right = false 
  59. end
  60.  
  61. local Bindings = {}
  62. Bindings["w"] = {Movement.ForwardOn,Movement.ForwardOff}
  63. Bindings["a"] = {Movement.LeftOn,Movement.LeftOff}
  64. Bindings["d"] = {Movement.RightOn,Movement.RightOff}
  65.  
  66.  
  67. mouse.KeyDown:connect(function(key)
  68.     if Bindings[key] then
  69.         Bindings[key][1]()
  70.     end
  71. end)
  72.  
  73. mouse.KeyUp:connect(function(key)
  74.     if Bindings[key] then
  75.         Bindings[key][2]()
  76.     end
  77. end)
  78.  
  79. Weeh = function()
  80.     local Base = script.Ship:Clone()
  81.     Base.Parent = game.Workspace
  82.    
  83.     player.Character.Humanoid.WalkSpeed = 10
  84.    
  85.     game:GetService("RunService").RenderStepped:connect(function()
  86.     local RockingSpeed = 6
  87.     local Offset = .5
  88.     local Rocking = (math.cos(time()*RockingSpeed)*Offset)     
  89.        
  90.     local Forward = (Movement.Forward and Speed or 0)
  91.     local Turning = ((Movement.Left and TurningSpeed) or (Movement.Right and -TurningSpeed) or (Movement.Left and Movement.Right and 0) or 0)
  92.  
  93.     local FD = cf(Base.Position)*cf(v3(),Base.CFrame.lookVector*1)*cfA(Rocking/10*rad(1),-Rocking*rad(1),Rocking*rad(.5))
  94.     Base.CFrame = FD
  95.     Base.CFrame = tweenCF(Base.CFrame,Base.CFrame*cf(0,Rocking,Forward)*cfA(0,Turning*rad(1),0),.1)
  96.     -- Base.CFrame (If it's one brick OR IF YOU HAVE WELDS: Do this: YourBasePart.Weld.C1 or C0 if you wish = tweenCF(Base.Weld.C1,Base.Weld.C1 etc
  97.     -- With the FD same story, use weld
  98.     end)   
  99.    
  100. end
  101.  
  102. wait(2)
  103. Weeh()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement