Advertisement
Fish_2651

ip gan

Nov 27th, 2021
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. local Library = loadstring(game:HttpGet("https://raw.githubusercontent.com/xHeptc/Kavo-UI-Library/main/source.lua"))()
  2. local Window = Library.CreateLib("TITLE", "Sentinel")
  3.  
  4. local Tab = Window:NewTab("Main")
  5. local Section = Tab:NewSection("Main")
  6.  
  7. Section:NewKeybind("Give Bomb to closest player", "PICK A KEY BIND DEFUALT IS =", Enum.KeyCode.=, function()
  8. local players = game:GetService("Players")
  9. local player = players.LocalPlayer
  10.  
  11. print("-----------------------------Loaded!-----------------------------")
  12. if game.Workspace[tostring(player)]:FindFirstChild("Bomb") then
  13. local function getClosestPlayer(from) --from = player to compare.
  14. local closest = {Player = nil, Magnitude = 0}--if there's no players in the server.
  15. local playerPosition = from.Character:WaitForChild("HumanoidRootPart").Position
  16.  
  17. for _, player in pairs(players:GetPlayers()) do
  18. if player == from then continue end
  19. --for every player do,
  20. local targetPosition = player.Character:WaitForChild("HumanoidRootPart").Position
  21. local magnitude = (targetPosition - playerPosition).Magnitude
  22. if magnitude < closest.Magnitude or closest.Magnitude == 0 then
  23. --if closer then,
  24. closest["Player"] = player; closest["Magnitude"] = magnitude
  25. end
  26. end
  27.  
  28. return closest.Player --returning the player or nil.
  29. end
  30.  
  31. local closestPlayer = getClosestPlayer(player)
  32. if closestPlayer then --if got player then
  33. print("The closest player is ", closestPlayer.Name)
  34. local oldPos = player.Character:WaitForChild("HumanoidRootPart").Position
  35. repeat
  36. player.Character.HumanoidRootPart.CFrame = CFrame.new(closestPlayer.Character.HumanoidRootPart.Position)
  37. wait(0.4)
  38. until game.Workspace[tostring(player)]:FindFirstChild("Bomb") == nil
  39. player.Character.HumanoidRootPart.CFrame = CFrame.new(oldPos)
  40. end
  41. end
  42.  
  43. game.Workspace:WaitForChild(tostring(player)).ChildAdded:Connect(function(child)
  44. if child.Name == "Bomb" then
  45. local function getClosestPlayer(from) --from = player to compare.
  46. local closest = {Player = nil, Magnitude = 0}--if there's no players in the server.
  47. local playerPosition = from.Character:WaitForChild("HumanoidRootPart").Position
  48.  
  49. for _, player in pairs(players:GetPlayers()) do
  50. if player == from then continue end
  51. --for every player do,
  52. local targetPosition = player.Character:WaitForChild("HumanoidRootPart").Position
  53. local magnitude = (targetPosition - playerPosition).Magnitude
  54. if magnitude < closest.Magnitude or closest.Magnitude == 0 then
  55. --if closer then,
  56. closest["Player"] = player; closest["Magnitude"] = magnitude
  57. end
  58. end
  59.  
  60. return closest.Player --returning the player or nil.
  61. end
  62.  
  63. local closestPlayer = getClosestPlayer(player)
  64. if closestPlayer then --if got player then
  65. print("The closest player is ", closestPlayer.Name)
  66. local oldPos = player.Character:WaitForChild("HumanoidRootPart").Position
  67. repeat
  68. player.Character.HumanoidRootPart.CFrame = CFrame.new(closestPlayer.Character.HumanoidRootPart.Position)
  69. wait(0.2)
  70. until game.Workspace[tostring(player)]:FindFirstChild("Bomb") == nil
  71. player.Character.HumanoidRootPart.CFrame = CFrame.new(oldPos)
  72. end
  73. end
  74. end)
  75. end)
  76.  
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement