Advertisement
xpa1nx0

Anime Dungeon Fighters Script 2

Jan 15th, 2024 (edited)
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. function autoupgradefunc()
  2. local success, err = pcall(function()
  3. local Players = game:GetService("Players")
  4. local UserInputService = game:GetService("UserInputService")
  5. local LocalPlayer = Players.LocalPlayer
  6. local attack = false
  7. local teleportEnabled = false
  8.  
  9. local function teleportPlayerBehind(humanoid)
  10. local humanoidRootPart = humanoid.Parent:FindFirstChild("HumanoidRootPart")
  11. local playerCharacter = LocalPlayer.Character
  12.  
  13. if humanoidRootPart and playerCharacter then
  14. local playerTorso = playerCharacter:FindFirstChild("HumanoidRootPart")
  15. if playerTorso then
  16. local newPosition = humanoidRootPart.Position - (humanoidRootPart.CFrame.LookVector * 5)
  17. playerCharacter:SetPrimaryPartCFrame(CFrame.new(newPosition))
  18. end
  19. end
  20. end
  21.  
  22. local function onKeyPress(input)
  23. if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.T then
  24. teleportEnabled = not teleportEnabled
  25. warn(teleportEnabled, "T")
  26. end
  27. end
  28.  
  29. local function getClosestEnemy()
  30. local closestEnemy = nil
  31. local closestDistance = math.huge
  32.  
  33. for _, descendant in pairs(game:GetService("Workspace")["副本地图"]:GetDescendants()) do
  34. if descendant:IsA("Model") and descendant:FindFirstChild("HumanoidRootPart") and descendant:FindFirstChild("Head") then
  35. local humanoid = descendant:FindFirstChildOfClass("Humanoid")
  36. local distance = (LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position - descendant:WaitForChild("HumanoidRootPart").Position).magnitude
  37.  
  38. if humanoid and humanoid.Health > 0 and distance < closestDistance and not Players:GetPlayerFromCharacter(descendant) then
  39. closestEnemy = humanoid
  40. closestDistance = distance
  41. end
  42. end
  43. end
  44.  
  45. return closestEnemy
  46. end
  47.  
  48. local function continuousTeleport()
  49. while task.wait() do
  50. if teleportEnabled then
  51. local closestEnemy = getClosestEnemy()
  52. if closestEnemy then
  53. teleportPlayerBehind(closestEnemy)
  54. end
  55. end
  56. end
  57. end
  58.  
  59. UserInputService.InputBegan:Connect(onKeyPress)
  60. coroutine.wrap(continuousTeleport)()
  61.  
  62. print("Loaded! 0.2")
  63.  
  64. end)
  65. if err then
  66. warn("//////////////////////////////////////////////////")
  67. getgenv().autoupgradeerr = true
  68. --error(err)
  69. end
  70. end
  71.  
  72. coroutine.resume(coroutine.create(function()
  73. while task.wait(2) do
  74. if getgenv().autoupgradeerr == true then
  75. task.wait()
  76. autoupgradefunc()
  77. getgenv().autoupgradeerr = false
  78. end
  79. end
  80. end))
  81.  
  82. pcall(function()
  83. autoupgradefunc()
  84. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement