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 1.91 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. }
  16. function MouseMoved()
  17.     local NewX,NewY=Mouse.X,Mouse.Y
  18.     if NewX>Cache.LastX then --Turn right
  19.         local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
  20.         local cF=CFrame.Angles(math.rad(_1),math.rad(_5),math.rad(_9))
  21.         Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(0,math.rad(-math.min(5,math.abs(NewX-Cache.LastX))*Settings.Sensitivity),0)
  22.         print("-x")
  23.     elseif NewX<Cache.LastX then --Turn left
  24.         local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
  25.         local cF=CFrame.Angles(math.rad(_1),math.rad(_5),math.rad(_9))
  26.         Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(0,math.rad(math.min(5,math.abs(NewX-Cache.LastX))*Settings.Sensitivity),0)
  27.         print("+x")
  28.     end
  29.     if NewY>Cache.LastY then --Look up
  30.         local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
  31.         local cF=CFrame.Angles(math.rad(_1),math.rad(_5),math.rad(_9))
  32.         Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(math.rad(-math.min(5,math.abs(NewY-Cache.LastY))*Settings.Sensitivity),0,0)
  33.         print("-y")
  34.     elseif NewY<Cache.LastY then --Look down
  35.         local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
  36.         local cF=CFrame.Angles(math.rad(_1),math.rad(_5),math.rad(_9))
  37.         Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(math.rad(math.min(5,math.abs(NewY-Cache.LastY))*Settings.Sensitivity),0,0)
  38.         print("+y")
  39.     end
  40.     script.CF.Value=Camera.CoordinateFrame
  41.     Cache.LastX=NewX
  42.     Cache.LastY=NewY
  43. end
  44. Mouse.Move:connect(MouseMoved)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement