Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.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
- for i,v in pairs(game.Players:GetPlayers()) do
- if v.Character and v:FindFirstChild("CamRot") then
- if v.Character.Humanoid.Health > 0 then
- local BaseTraverseTime = .7
- local traversetimecalc = math.abs((math.rad(v.Character.Head.Orientation.Y) - math.rad(180)) - math.rad(v.CamRot.Value))
- if traversetimecalc > math.rad(180) or traversetimecalc < math.rad(-180) then
- local correct = math.abs(math.rad(360) - traversetimecalc)
- TraverseTime = BaseTraverseTime * correct
- else
- TraverseTime = BaseTraverseTime * traversetimecalc
- end
- local info = TweenInfo.new(TraverseTime,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
- local goal = {}
- goal.C0 = CFrame.new(0,0,0)*CFrame.Angles(0,math.rad(90) + math.rad(v.CamRot.Value) - math.rad(v.Character.HumanoidRootPart.Orientation.Y),0)
- local tween = TS:Create(v.Character.Turret.Traverse,info,goal)
- tween:Play()
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement