Advertisement
BjeffeHund

Untitled

Apr 25th, 2020
4,421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. local cc = game:GetService("Workspace").CurrentCamera
  2. function getSquare()
  3. local last = math.huge
  4. local nearest = nil
  5. for i,v in pairs(game.workspace:GetDescendants()) do
  6. if v:IsA("Part") and v:FindFirstChildWhichIsA("SelectionBox") then
  7. local distance = (game:GetService("Workspace").Client.CameraPos.Position - v.Position).magnitude
  8. if distance < last then
  9. last = distance
  10. nearest = v
  11. end
  12. end
  13. end
  14. if nearest ~= nil then
  15. return nearest
  16. end
  17. end
  18. game:GetService('RunService').Stepped:connect(function()
  19. if game:GetService("Workspace").Client:FindFirstChild("Background") then
  20. local lol = getSquare()
  21. local bet1 = -0.4
  22. local bet2 = 1.1
  23. lol.CFrame = CFrame.new(lol.CFrame.x + math.random(bet1,bet2), lol.CFrame.y + math.random(bet1,bet2), lol.CFrame.z + math.random(bet1,bet2))
  24. cc.CFrame = CFrame.new(cc.CFrame.p, lol.CFrame.p)
  25. end
  26. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement