Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player=game.Players.LocalPlayer
- local Camera=workspace.CurrentCamera
- local Mouse=Player:GetMouse()
- repeat wait() until workspace:FindFirstChild(Player.Name.."_Body")
- local Body=workspace:FindFirstChild(Player.Name.."_Body")
- Player.Character.Humanoid.AutoRotate=false
- local Settings={
- InvertedX=false,
- InvertedY=false,
- Sensitivity=1
- }
- local Cache={
- LastX=Mouse.X,
- LastY=Mouse.Y,
- prevCF=CFrame.new()
- }
- function Update()
- Camera.CameraType="Scriptable"
- local NewX,NewY=Mouse.X,Mouse.Y
- script.CF.Value=Camera.CoordinateFrame
- if NewX>Cache.LastX then --Turn right
- local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
- 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))
- Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(0,math.rad(-math.min(5,math.abs(NewX-Cache.LastX))*Settings.Sensitivity),0)
- script.CF.Value=Camera.CoordinateFrame
- end
- if NewX<Cache.LastX then --Turn left
- local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
- 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))
- Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(0,math.rad(math.min(5,math.abs(NewX-Cache.LastX))*Settings.Sensitivity),0)
- script.CF.Value=Camera.CoordinateFrame
- end
- if NewY>Cache.LastY then --Look up
- local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
- 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))
- Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(math.rad(-math.min(5,math.abs(NewY-Cache.LastY))*Settings.Sensitivity),0,0)
- script.CF.Value=Camera.CoordinateFrame
- end
- if NewY<Cache.LastY then --Look down
- local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
- 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))
- Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF*CFrame.Angles(math.rad(math.min(5,math.abs(NewY-Cache.LastY))*Settings.Sensitivity),0,0)
- script.CF.Value=Camera.CoordinateFrame
- end
- script.CF.Value=Camera.CoordinateFrame
- Cache.LastX=NewX
- Cache.LastY=NewY
- Cache.prevCF=Body.Head.CFrame
- local X,Y,Z,_1,_2,_3,_4,_5,_6,_7,_8,_9=script.CF.Value:components()
- 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))
- Camera.CoordinateFrame=CFrame.new(Body.Head.Position)*cF
- end
- coroutine.wrap(function()
- while true do
- game:GetService("RunService").RenderStepped:wait()
- Update()
- end
- end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement