Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- run = game:GetService("RunService")
- local player = game.Players.LocalPlayer
- script:WaitForChild("Follow")
- if not player.Character then player.CharacterAdded:wait() end
- if not game.Workspace then game:WaitForChild("Workspace") end
- local cam = game.Workspace.CurrentCamera
- cam.CameraType = Enum.CameraType.Scriptable
- cam.FieldOfView = 35
- local ignored = {}
- run.RenderStepped:connect(function()
- if player.Character:FindFirstChild("HumanoidRootPart") and script.Follow.Value then
- local pushdet = Ray.new(player.Character.Head.CFrame.p , Vector3.new(0,math.tan(math.pi/12),1).unit*70)
- local rays = {
- Ray.new(player.Character.Head.CFrame.p + Vector3.new(0,2,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
- Ray.new(player.Character.Head.CFrame.p + Vector3.new(0,1,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
- Ray.new(player.Character.Head.CFrame.p + Vector3.new(0,-2,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
- Ray.new(player.Character.HumanoidRootPart.CFrame.p, Vector3.new(0,math.tan(math.pi/12),1).unit*70),
- Ray.new(player.Character.HumanoidRootPart.CFrame.p + Vector3.new(1,0,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
- Ray.new(player.Character.HumanoidRootPart.CFrame.p + Vector3.new(-1,0,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
- Ray.new(player.Character.HumanoidRootPart.CFrame.p + Vector3.new(2,0,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
- Ray.new(player.Character.HumanoidRootPart.CFrame.p + Vector3.new(-2,0,0), Vector3.new(0,math.tan(math.pi/12),1).unit*70),
- }
- for _,v in pairs(player.Character:GetChildren()) do
- if v:IsA"BasePart" then
- table.insert(rays, Ray.new(v.CFrame.p, Vector3.new(0,math.tan(math.pi/12),1).unit*100))
- end
- end
- local ph, pp = game.Workspace:FindPartOnRayWithIgnoreList(pushdet, {player.Character})
- local allhit = ph ~= nil
- for _,v in pairs(rays) do
- local h,p = game.Workspace:FindPartOnRayWithIgnoreList(v, {player.Character})
- if not h and allhit then
- allhit = false
- end
- end
- if allhit then
- local push = (player.Character.Head.CFrame.p - pp).magnitude
- cam.CoordinateFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.Angles(-(math.pi/12), 0, 0) * CFrame.new(0,4,math.min(80,push))
- else
- cam.CoordinateFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.Angles(-(math.pi/12), 0, 0) * CFrame.new(0,4,80)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement