Advertisement
s0uthw3st

Untitled

Aug 23rd, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 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. function CFrameFromTopBack(at, top, back)
  10.     local right = top:Cross(back)
  11.     return cf(at.x,at.y,at.z,
  12.         right.x,top.x,back.x,
  13.         right.y,top.y,back.y,
  14.         right.z,top.z,back.z)
  15. end
  16.  
  17. function tweenCF(startCF,endCF,Step)
  18.     local startTop = (startCF*cfA(rad(90),0,0)).lookVector
  19.     local startBack = startCF.lookVector*-1
  20.     local endTop = (endCF*cfA(rad(90),0,0)).lookVector
  21.     local endBack = endCF.lookVector*-1
  22.     local startPos = startCF.p
  23.     local endPos = endCF.p
  24.     local newCF = CFrameFromTopBack(startPos:lerp(endPos,Step),startTop:lerp(endTop,Step),startBack:lerp(endBack,Step))
  25.     return newCF
  26. end
  27.  
  28. Weeh = function()
  29.     local Base = script.Parent
  30.    
  31.     local Movement = {["Forward"] = 0, ["Left"] = 0, ["Right"] = 0}
  32.     game:GetService("RunService").RenderStepped:connect(function()
  33.     Movement.Left = false
  34.     Movement.Right = false
  35.     Movement.Forward = false
  36.     local RockingSpeed = 2
  37.     local Offset = .625
  38.     local Rocking = (math.cos(time()*RockingSpeed)*Offset)     
  39.        
  40.     local Forward = (Movement.Forward and Speed or 0)
  41.     local Turning = ((Movement.Left and TurningSpeed) or (Movement.Right and -TurningSpeed) or (Movement.Left and Movement.Right and 0) or 0)
  42.  
  43.     local FD = cf(Base.Position)*cf(v3(),Base.CFrame.lookVector*1)*cfA(Rocking/10*rad(1),0,Rocking*rad(3))
  44.     Base.CFrame = FD
  45.     Base.CFrame = tweenCF(Base.CFrame,Base.CFrame*cf(0,Rocking/2,Forward)*cfA(0,Turning*rad(1),0),.1)
  46.     -- 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
  47.     -- With the FD same story, use weld
  48.     end)   
  49.    
  50. end
  51.  
  52. wait(2)
  53. Weeh()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement