Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local cam = workspace.CurrentCamera
- local UserInputService = game:GetService("UserInputService")
- local mouse = player:GetMouse()
- local character = player.Character
- repeat wait() character = player.Character until character
- local head = character:WaitForChild("Head")
- local humanoid = character:WaitForChild("Humanoid")
- local sin = math.sin
- local cos = math.cos
- local rad = math.rad
- local CF = CFrame.new
- local CFAngles = CFrame.Angles
- local wobbleCF = CF()
- local zero = CF()
- local wobble = 0
- local wobbleY = 0
- local dir = 1
- local dirY = 1
- local Sensitivity = 5
- local mouse_V = 0
- local mouse_H = 0
- local MAX_V_UP = rad(80)
- local MAX_V_DN = rad(-80)
- local function constrain(min, max, num)
- return num < min and min or num > max and max or num
- end
- UserInputService.InputChanged:connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement then
- mouse_V = constrain(MAX_V_DN, MAX_V_UP, mouse_V + rad(input.Delta.Y/Sensitivity))
- mouse_H = mouse_H + rad(input.Delta.x/Sensitivity)
- end
- end)
- local walking = false
- local speed = 1
- humanoid.Running:Connect(function(s)
- if s > 1 then
- speed = s
- walking = true
- else
- walking = false
- end
- end)
- game:GetService("RunService").RenderStepped:connect(function()
- UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
- cam.CameraType = Enum.CameraType.Scriptable
- if walking then
- wobbleCF = wobbleCF:lerp(
- CFAngles(0,0,rad(wobble))
- ,.3)
- wobble = wobble + dir*.15*(speed/16)
- if math.abs(wobble) > 2 then
- dir = -dir
- end
- wobbleY = wobbleY + dirY*.3*(speed/16)
- if math.abs(wobbleY) > 4 then
- dirY = -dirY
- end
- else
- wobble = 0
- wobbleY = 0
- wobbleCF = wobbleCF:lerp(zero,.2)
- end
- local rotation = CFAngles(0, -mouse_H, 0)
- local rotation2 = CFAngles(-mouse_V, 0, 0)
- local baseCFrame = CF(head.Position)
- local nextCam = baseCFrame * rotation * rotation2 * CF(0,0,-1)
- cam.CameraType = Enum.CameraType.Scriptable
- cam:Interpolate(baseCFrame* rotation *wobbleCF,nextCam*CF(0,rad(wobbleY*.1),0),0.01)
- for _, v in pairs(character:GetChildren())do
- if v:IsA'Part' then
- v.LocalTransparencyModifier = 1
- for _, hat in pairs(character:GetChildren())do
- if hat:IsA'Accessory' then
- hat.Handle.LocalTransparencyModifier = 1
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment