Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Library = loadstring(game:HttpGet("https://raw.githubusercontent.com/xHeptc/Kavo-UI-Library/main/source.lua"))()
- local Window = Library.CreateLib("TITLE", "Sentinel")
- local Tab = Window:NewTab("Main")
- local Section = Tab:NewSection("Main")
- Section:NewKeybind("Give Bomb to closest player", "PICK A KEY BIND DEFUALT IS =", Enum.KeyCode.=, function()
- local players = game:GetService("Players")
- local player = players.LocalPlayer
- print("-----------------------------Loaded!-----------------------------")
- if game.Workspace[tostring(player)]:FindFirstChild("Bomb") then
- local function getClosestPlayer(from) --from = player to compare.
- local closest = {Player = nil, Magnitude = 0}--if there's no players in the server.
- local playerPosition = from.Character:WaitForChild("HumanoidRootPart").Position
- for _, player in pairs(players:GetPlayers()) do
- if player == from then continue end
- --for every player do,
- local targetPosition = player.Character:WaitForChild("HumanoidRootPart").Position
- local magnitude = (targetPosition - playerPosition).Magnitude
- if magnitude < closest.Magnitude or closest.Magnitude == 0 then
- --if closer then,
- closest["Player"] = player; closest["Magnitude"] = magnitude
- end
- end
- return closest.Player --returning the player or nil.
- end
- local closestPlayer = getClosestPlayer(player)
- if closestPlayer then --if got player then
- print("The closest player is ", closestPlayer.Name)
- local oldPos = player.Character:WaitForChild("HumanoidRootPart").Position
- repeat
- player.Character.HumanoidRootPart.CFrame = CFrame.new(closestPlayer.Character.HumanoidRootPart.Position)
- wait(0.4)
- until game.Workspace[tostring(player)]:FindFirstChild("Bomb") == nil
- player.Character.HumanoidRootPart.CFrame = CFrame.new(oldPos)
- end
- end
- game.Workspace:WaitForChild(tostring(player)).ChildAdded:Connect(function(child)
- if child.Name == "Bomb" then
- local function getClosestPlayer(from) --from = player to compare.
- local closest = {Player = nil, Magnitude = 0}--if there's no players in the server.
- local playerPosition = from.Character:WaitForChild("HumanoidRootPart").Position
- for _, player in pairs(players:GetPlayers()) do
- if player == from then continue end
- --for every player do,
- local targetPosition = player.Character:WaitForChild("HumanoidRootPart").Position
- local magnitude = (targetPosition - playerPosition).Magnitude
- if magnitude < closest.Magnitude or closest.Magnitude == 0 then
- --if closer then,
- closest["Player"] = player; closest["Magnitude"] = magnitude
- end
- end
- return closest.Player --returning the player or nil.
- end
- local closestPlayer = getClosestPlayer(player)
- if closestPlayer then --if got player then
- print("The closest player is ", closestPlayer.Name)
- local oldPos = player.Character:WaitForChild("HumanoidRootPart").Position
- repeat
- player.Character.HumanoidRootPart.CFrame = CFrame.new(closestPlayer.Character.HumanoidRootPart.Position)
- wait(0.2)
- until game.Workspace[tostring(player)]:FindFirstChild("Bomb") == nil
- player.Character.HumanoidRootPart.CFrame = CFrame.new(oldPos)
- end
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement