Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cc = game:GetService("Workspace").CurrentCamera
- function getSquare()
- local last = math.huge
- local nearest = nil
- for i,v in pairs(game.workspace:GetDescendants()) do
- if v:IsA("Part") and v:FindFirstChildWhichIsA("SelectionBox") then
- local distance = (game:GetService("Workspace").Client.CameraPos.Position - v.Position).magnitude
- if distance < last then
- last = distance
- nearest = v
- end
- end
- end
- if nearest ~= nil then
- return nearest
- end
- end
- game:GetService('RunService').Stepped:connect(function()
- if game:GetService("Workspace").Client:FindFirstChild("Background") then
- local lol = getSquare()
- local bet1 = -0.4
- local bet2 = 1.1
- 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))
- cc.CFrame = CFrame.new(cc.CFrame.p, lol.CFrame.p)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement