Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.82 KB | None | 0 0
  1. local Player=game.Players.LocalPlayer
  2. local Camera=workspace.CurrentCamera
  3. local Mouse=Player:GetMouse()
  4. repeat wait() until workspace:FindFirstChild(Player.Name.."_Body")
  5. local Body=workspace:FindFirstChild(Player.Name.."_Body")
  6. Player.Character.Humanoid.AutoRotate=false
  7. local Settings={
  8.     InvertedX=false,
  9.     InvertedY=false,
  10.     Sensitivity=1
  11. }
  12. local Cache={
  13.     LastX=Mouse.X,
  14.     LastY=Mouse.Y,
  15.     prevCF=CFrame.new()
  16. }
  17. function Update()
  18.     Camera.CameraType="Scriptable"
  19.     local NewX,NewY=Mouse.X,Mouse.Y
  20.     script.CF.Value=Camera.CoordinateFrame
  21.     if NewX>Cache.LastX then --Turn right
  22.         local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
  23.         local cF=CFrame.new(0,0,0,math.rad(_1),math.rad(_2),math.rad(_3),math.rad(_4),math.rad(_5),math.rad(_6),math.rad(_7),math.rad(_8),math.rad(_9))
  24.         Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(0,math.rad(-math.min(5,math.abs(NewX-Cache.LastX))*Settings.Sensitivity),0)
  25.         script.CF.Value=Camera.CoordinateFrame
  26.     end
  27.     if NewX<Cache.LastX then --Turn left
  28.         local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
  29.         local cF=CFrame.new(0,0,0,math.rad(_1),math.rad(_2),math.rad(_3),math.rad(_4),math.rad(_5),math.rad(_6),math.rad(_7),math.rad(_8),math.rad(_9))
  30.         Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(0,math.rad(math.min(5,math.abs(NewX-Cache.LastX))*Settings.Sensitivity),0)
  31.         script.CF.Value=Camera.CoordinateFrame
  32.     end
  33.     if NewY>Cache.LastY then --Look up
  34.         local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
  35.         local cF=CFrame.new(0,0,0,math.rad(_1),math.rad(_2),math.rad(_3),math.rad(_4),math.rad(_5),math.rad(_6),math.rad(_7),math.rad(_8),math.rad(_9))
  36.         Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(math.rad(-math.min(5,math.abs(NewY-Cache.LastY))*Settings.Sensitivity),0,0)
  37.         script.CF.Value=Camera.CoordinateFrame
  38.     end
  39.     if NewY<Cache.LastY then --Look down
  40.         local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
  41.         local cF=CFrame.new(0,0,0,math.rad(_1),math.rad(_2),math.rad(_3),math.rad(_4),math.rad(_5),math.rad(_6),math.rad(_7),math.rad(_8),math.rad(_9))
  42.         Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(math.rad(math.min(5,math.abs(NewY-Cache.LastY))*Settings.Sensitivity),0,0)
  43.         script.CF.Value=Camera.CoordinateFrame
  44.     end
  45.     script.CF.Value=Camera.CoordinateFrame
  46.     Cache.LastX=NewX
  47.     Cache.LastY=NewY
  48.     Cache.prevCF=Body.Head.CFrame
  49.     local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
  50.     local cF=CFrame.new(0,0,0,math.rad(_1),math.rad(_2),math.rad(_3),math.rad(_4),math.rad(_5),math.rad(_6),math.rad(_7),math.rad(_8),math.rad(_9))
  51.     Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF
  52. end
  53. coroutine.wrap(function()
  54.     while true do
  55.         game:GetService("RunService").RenderStepped:wait()
  56.         Update()
  57.     end
  58. end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement