Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cam = workspace.CurrentCamera
- cam.RobloxLocked = true
- local orgType = cam.CameraType
- local target
- local function UpdateTarget()
- local closest = nil
- for i,v in pairs(workspace.Client.Cubes:GetChildren()) do
- if v.Name == "Cube" then
- local vP = v.Position
- if closest == nil then
- closest = v
- else
- if (workspace.Client.CameraPos.Position-vP).magnitude < (workspace.Client.CameraPos.Position-closest.Position).magnitude then
- closest = v
- end
- end
- end
- end
- target = closest
- end
- while wait() do
- if game.Players.LocalPlayer.MapData.Playing.Value then
- UpdateTarget()
- pcall(function()
- local pos = Vector3.new(cam.CFrame.X,cam.CFrame.Y,cam.CFrame.Z)
- local lookAt = Vector3.new(target.Position.X,target.Position.Y,target.Position.Z)
- cam.CameraType = Enum.CameraType.Scriptable
- cam.CFrame = CFrame.new(pos,lookAt)
- end)
- else
- cam.CameraType = orgType
- end
- end
Add Comment
Please, Sign In to add comment