sucksuck

Untitled

Mar 5th, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. -- Define the teleport function
  2. local function teleportToPlayer(targetPlayer)
  3. local distance = (targetPlayer.Character.HumanoidRootPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude
  4. local tweenInfo = TweenInfo.new(distance/100, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
  5. local tween = game:GetService("TweenService"):Create(game.Players.LocalPlayer.Character.HumanoidRootPart, tweenInfo, {CFrame = targetPlayer.Character.HumanoidRootPart.CFrame - targetPlayer.Character.HumanoidRootPart.CFrame.LookVector * 3})
  6. tween:Play()
  7. end
  8.  
  9. -- Define the loop function
  10. local function loopTeleport()
  11. local nearestPlayer = nil
  12. local nearestDistance = math.huge
  13.  
  14. -- Find the nearest player
  15. for _, player in pairs(game.Players:GetPlayers()) do
  16. if player ~= game.Players.LocalPlayer then
  17. local distance = (player.Character.HumanoidRootPart.Position - game.Players.LocalPlayer.Character.HumanoidRootPart.Position).Magnitude
  18. if distance < nearestDistance then
  19. nearestPlayer = player
  20. nearestDistance = distance
  21. end
  22. end
  23. end
  24.  
  25. -- Teleport to the nearest player
  26. if nearestPlayer then
  27. teleportToPlayer(nearestPlayer)
  28. end
  29. end
  30.  
  31. -- Start the loop
  32. local toggleValue = false
  33. local toggleButton = nil
  34. spawn(function()
  35. while true do
  36. if toggleValue then
  37. loopTeleport()
  38. end
  39. wait(0)
  40. end
  41. end)
Advertisement
Add Comment
Please, Sign In to add comment