Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cam = game.workspace.CurrentCamera
- local Targets = {}
- local Distances = {}
- local lpr = game.Players.LocalPlayer
- local mouse = lpr:GetMouse()
- local Target = ""
- local target = nil
- game:GetService("RunService").RenderStepped:connect(function()
- if game.Players.LocalPlayer.Character then
- for c,d in pairs(Targets) do
- table.remove(Targets,c)
- end
- for k,j in pairs(Distances) do
- table.remove(Distances,k)
- end
- for i,v in next, game.Players:GetChildren() do
- if v.Name ~= game.Players.LocalPlayer.Name then
- local Distance = (game.Players.LocalPlayer.Character.HumanoidRootPart.Position-v.Character.HumanoidRootPart.Position).magnitude
- table.insert(Targets,{v.Name,Distance})
- table.insert(Distances,Distance)
- end
- end
- for _,t in next, Targets do
- if t[2] == math.min(unpack(Distances)) then
- Target = t[1]
- end
- end
- if game.Players:FindFirstChild(Target) then
- target = game.Players:FindFirstChild(Target)
- end
- end
- if mousedown == true then
- cam.CoordinateFrame = CFrame.new(cam.Focus.p,target.Character.Head.Position)
- end
- end)
- mouse.Button2Down:connect(function()
- if mousedown == true then
- mousedown = false
- else
- mousedown = true
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement