saito1

grimshot

Jan 23rd, 2022 (edited)
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. local p = game.Players.LocalPlayer
  2. local c = p.Character
  3.  
  4. function nearest()
  5.     local Closest
  6.     local Distance = math.huge
  7.     for _,v in pairs(game:GetService("Workspace"):GetDescendants()) do
  8.         if (v.Name == "Copper" or v.Name == "Iron" or v.Name == "Gold" or v.Name == "Diamond" or v.Name == "Crystal") and v:FindFirstChild("MoveHere") then
  9.             local newDistance = (v.MoveHere.Position - c.HumanoidRootPart.Position).magnitude
  10.             if newDistance < Distance then
  11.                 Closest = v
  12.                 Distance = newDistance
  13.             end
  14.         end
  15.     end
  16.     return Closest
  17. end
  18.  
  19. local n = nearest()
  20.  
  21.  
  22. c.HumanoidRootPart.CFrame = n.MoveHere.CFrame*CFrame.new(0,5,0)
  23. game.ReplicatedStorage.JobRemotes.Mining:FireServer(n:FindFirstChild("MoveHere"))
  24.  
Add Comment
Please, Sign In to add comment