Advertisement
KrystekYY

Untitled

Jul 20th, 2022
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. local closestCoin = nil
  2. local lastCoin = math.huge
  3. spawn(function()
  4. while task.wait(1) do
  5. local plrWorld = tostring(game:GetService("Players").LocalPlayer.Leaderstats.currentWorld.Value)
  6. local a = game:GetService("Workspace")["__THINGS"].Coins[plrWorld]:GetChildren()
  7. local b = game.Players.LocalPlayer.Character.HumanoidRootPart
  8. lastCoin = math.huge
  9. for i,v in pairs(a) do
  10. if v ~= nil and v:FindFirstChild("Coin") ~= nil and game:GetService("Workspace")["__THINGS"].Coins:FindFirstChild(plrWorld) then
  11. local distance = (b.Position - v.Coin.Position).magnitude
  12. if distance < lastCoin then
  13. closestCoin = v
  14. lastCoin = distance
  15. end
  16. end
  17. end
  18. end
  19. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement