Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local cam = workspace.CurrentCamera
- local rs = game.ReplicatedStorage
- local UIS = game:GetService("UserInputService")
- local TS = game:GetService("TweenService")
- repeat wait() until player.Character and player:FindFirstChild("CamRot")
- local part = Instance.new("Part",cam)
- part.Transparency = 1
- part.Anchored = true
- part.CanCollide = false
- local Char = player.Character
- local Root = player.Character.HumanoidRootPart
- local Time
- local TraverseTime
- local GoalRad
- local calc
- game:GetService("RunService").RenderStepped:Connect(function()
- local rot = require(player.PlayerScripts:WaitForChild("ControlScript").MasterControl):GetMoveVector()
- local RotGoal = {}
- if rot == Vector3.new(0,0,-1) then
- RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(0) + math.rad(player.CamRot.Value),0)
- GoalRad = math.rad(0) + math.rad(player.CamRot.Value)
- elseif rot == Vector3.new(0,0,1) then
- RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(180) + math.rad(player.CamRot.Value),0)
- GoalRad = math.rad(180) + math.rad(player.CamRot.Value)
- elseif rot == Vector3.new(1,0,0) then
- RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(-90) + math.rad(player.CamRot.Value),0)
- GoalRad = math.rad(-90) + math.rad(player.CamRot.Value)
- elseif rot == Vector3.new(-1,0,0) then
- RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(90) + math.rad(player.CamRot.Value),0)
- GoalRad = math.rad(90) + math.rad(player.CamRot.Value)
- elseif rot == Vector3.new(1,0,-1) then
- RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(-45) + math.rad(player.CamRot.Value),0)
- GoalRad = math.rad(-45) + math.rad(player.CamRot.Value)
- elseif rot == Vector3.new(-1,0,-1) then
- RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(45) + math.rad(player.CamRot.Value),0)
- GoalRad = math.rad(45) + math.rad(player.CamRot.Value)
- elseif rot == Vector3.new(-1,0,1) then
- RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(135) + math.rad(player.CamRot.Value),0)
- GoalRad = math.rad(135) + math.rad(player.CamRot.Value)
- elseif rot == Vector3.new(1,0,1) then
- RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(-135) + math.rad(player.CamRot.Value),0)
- GoalRad = math.rad(-135) + math.rad(player.CamRot.Value)
- elseif rot == Vector3.new(0,0,0) then
- GoalRad = 0 + math.rad(player.CamRot.Value)
- end
- local Base = .65
- calc = math.abs(GoalRad - math.rad(Root.Orientation.Y))
- if calc > math.rad(180) or calc < math.rad(-180) then
- local correct = math.abs(math.rad(360) - calc)
- Time = Base * correct
- Char.Humanoid.WalkSpeed = Char.MechSpeed.Value - (correct*Char.DeltaGradient.Value)
- else
- Time = Base * calc
- Char.Humanoid.WalkSpeed = Char.MechSpeed.Value - (calc*Char.DeltaGradient.Value)
- end
- local RotInfo = TweenInfo.new(Time,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
- local RotTween = TS:Create(player.Character.HumanoidRootPart,RotInfo,RotGoal)
- RotTween:Play()
- part.CFrame = cam.CFrame
- if player:FindFirstChild("CamRot") then
- rs.SetRot:FireServer(part.Orientation.Y)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement