Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. run = game:GetService("RunService")
  2. local player = game.Players.LocalPlayer
  3.  
  4.  
  5. script:WaitForChild("Follow")
  6. if not player.Character then player.CharacterAdded:wait() end
  7.  
  8. if not game.Workspace then game:WaitForChild("Workspace") end
  9.  
  10. local cam = game.Workspace.CurrentCamera
  11. cam.CameraType = Enum.CameraType.Scriptable
  12. cam.FieldOfView = 35
  13.  
  14. local ignored = {}
  15.  
  16. run.RenderStepped:connect(function()
  17.     if player.Character:FindFirstChild("HumanoidRootPart") and script.Follow.Value then
  18.        
  19.         local pushdet = Ray.new(player.Character.Head.CFrame.p , Vector3.new(0,math.tan(math.pi/12),1).unit*70)
  20.         local rays = {
  21.             Ray.new(player.Character.Head.CFrame.p + Vector3.new(0,2,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
  22.             Ray.new(player.Character.Head.CFrame.p + Vector3.new(0,1,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
  23.             Ray.new(player.Character.Head.CFrame.p + Vector3.new(0,-2,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
  24.             Ray.new(player.Character.HumanoidRootPart.CFrame.p, Vector3.new(0,math.tan(math.pi/12),1).unit*70),
  25.             Ray.new(player.Character.HumanoidRootPart.CFrame.p + Vector3.new(1,0,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
  26.             Ray.new(player.Character.HumanoidRootPart.CFrame.p + Vector3.new(-1,0,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
  27.             Ray.new(player.Character.HumanoidRootPart.CFrame.p + Vector3.new(2,0,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
  28.             Ray.new(player.Character.HumanoidRootPart.CFrame.p + Vector3.new(-2,0,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
  29.         }
  30.        
  31.         for _,v in pairs(player.Character:GetChildren()) do
  32.             if v:IsA"BasePart" then
  33.                 table.insert(rays, Ray.new(v.CFrame.p, Vector3.new(0,math.tan(math.pi/12),1).unit*100))
  34.             end
  35.         end
  36.        
  37.         local ph, pp = game.Workspace:FindPartOnRayWithIgnoreList(pushdet, {player.Character})
  38.        
  39.         local allhit = ph ~= nil
  40.                
  41.         for _,v in pairs(rays) do
  42.             local h,p = game.Workspace:FindPartOnRayWithIgnoreList(v, {player.Character})
  43.             if not h and allhit then
  44.                 allhit = false
  45.             end
  46.         end
  47.        
  48.         if allhit then
  49.             local push = (player.Character.Head.CFrame.p - pp).magnitude
  50.             cam.CoordinateFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.Angles(-(math.pi/12), 0, 0) * CFrame.new(0,4,math.min(80,push))
  51.         else
  52.             cam.CoordinateFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.Angles(-(math.pi/12), 0, 0) * CFrame.new(0,4,80) 
  53.         end                
  54.     end
  55. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement