Advertisement
Guest User

Untitled

a guest
Sep 30th, 2018
1,333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.12 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local mouse = player:GetMouse()
  3. local cam = workspace.CurrentCamera
  4. local rs = game.ReplicatedStorage
  5. local UIS = game:GetService("UserInputService")
  6. local TS = game:GetService("TweenService")
  7.  
  8. repeat wait() until player.Character and player:FindFirstChild("CamRot")
  9.  
  10. local part = Instance.new("Part",cam)
  11. part.Transparency = 1
  12. part.Anchored = true
  13. part.CanCollide = false
  14.  
  15. local Char = player.Character
  16. local Root = player.Character.HumanoidRootPart
  17. local Time
  18. local TraverseTime
  19.  
  20. local GoalRad
  21. local calc
  22.  
  23.  
  24. game:GetService("RunService").RenderStepped:Connect(function()
  25.  
  26. local rot = require(player.PlayerScripts:WaitForChild("ControlScript").MasterControl):GetMoveVector()
  27.  
  28. local RotGoal = {}
  29.  
  30. if rot == Vector3.new(0,0,-1) then
  31.     RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(0) + math.rad(player.CamRot.Value),0)
  32.     GoalRad = math.rad(0) + math.rad(player.CamRot.Value)
  33.    
  34. elseif rot == Vector3.new(0,0,1) then
  35.     RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(180) + math.rad(player.CamRot.Value),0)
  36.     GoalRad = math.rad(180) + math.rad(player.CamRot.Value)
  37.    
  38. elseif rot == Vector3.new(1,0,0) then
  39.     RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(-90) + math.rad(player.CamRot.Value),0)
  40.     GoalRad = math.rad(-90) + math.rad(player.CamRot.Value)
  41.    
  42. elseif rot == Vector3.new(-1,0,0) then
  43.     RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(90) + math.rad(player.CamRot.Value),0)
  44.     GoalRad = math.rad(90) + math.rad(player.CamRot.Value)
  45.    
  46. elseif rot == Vector3.new(1,0,-1) then
  47.     RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(-45) + math.rad(player.CamRot.Value),0)
  48.     GoalRad = math.rad(-45) + math.rad(player.CamRot.Value)
  49.    
  50. elseif rot == Vector3.new(-1,0,-1) then
  51.     RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(45) + math.rad(player.CamRot.Value),0)
  52.     GoalRad = math.rad(45) + math.rad(player.CamRot.Value)
  53.    
  54. elseif rot == Vector3.new(-1,0,1) then
  55.     RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(135) + math.rad(player.CamRot.Value),0)
  56.     GoalRad = math.rad(135) + math.rad(player.CamRot.Value)
  57.    
  58. elseif rot == Vector3.new(1,0,1) then
  59.     RotGoal.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,math.rad(-135) + math.rad(player.CamRot.Value),0)
  60.     GoalRad = math.rad(-135) + math.rad(player.CamRot.Value)
  61.    
  62. elseif rot == Vector3.new(0,0,0) then
  63.     GoalRad = 0 + math.rad(player.CamRot.Value)
  64. end
  65.  
  66. local Base = .65
  67.  
  68. calc = math.abs(GoalRad - math.rad(Root.Orientation.Y))
  69.  
  70. if calc > math.rad(180) or calc < math.rad(-180) then
  71. local correct = math.abs(math.rad(360) - calc)
  72. Time = Base * correct
  73. Char.Humanoid.WalkSpeed = Char.MechSpeed.Value - (correct*Char.DeltaGradient.Value)
  74. else
  75. Time = Base * calc
  76. Char.Humanoid.WalkSpeed = Char.MechSpeed.Value - (calc*Char.DeltaGradient.Value)
  77. end
  78.  
  79.  
  80.  
  81. local RotInfo = TweenInfo.new(Time,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
  82.  
  83.  
  84. local RotTween = TS:Create(player.Character.HumanoidRootPart,RotInfo,RotGoal)          
  85. RotTween:Play()
  86.  
  87.    
  88.     part.CFrame = cam.CFrame
  89.    
  90.     if player:FindFirstChild("CamRot") then
  91.     rs.SetRot:FireServer(part.Orientation.Y)
  92.     end
  93. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement