Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function autoupgradefunc()
- local success, err = pcall(function()
- local Players = game:GetService("Players")
- local UserInputService = game:GetService("UserInputService")
- local LocalPlayer = Players.LocalPlayer
- local attack = false
- local teleportEnabled = false
- local function teleportPlayerBehind(humanoid)
- local humanoidRootPart = humanoid.Parent:FindFirstChild("HumanoidRootPart")
- local playerCharacter = LocalPlayer.Character
- if humanoidRootPart and playerCharacter then
- local playerTorso = playerCharacter:FindFirstChild("HumanoidRootPart")
- if playerTorso then
- local newPosition = humanoidRootPart.Position - (humanoidRootPart.CFrame.LookVector * 5)
- playerCharacter:SetPrimaryPartCFrame(CFrame.new(newPosition))
- end
- end
- end
- local function onKeyPress(input)
- if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.T then
- teleportEnabled = not teleportEnabled
- warn(teleportEnabled, "T")
- end
- end
- local function getClosestEnemy()
- local closestEnemy = nil
- local closestDistance = math.huge
- for _, descendant in pairs(game:GetService("Workspace")["副本地图"]:GetDescendants()) do
- if descendant:IsA("Model") and descendant:FindFirstChild("HumanoidRootPart") and descendant:FindFirstChild("Head") then
- local humanoid = descendant:FindFirstChildOfClass("Humanoid")
- local distance = (LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position - descendant:WaitForChild("HumanoidRootPart").Position).magnitude
- if humanoid and humanoid.Health > 0 and distance < closestDistance and not Players:GetPlayerFromCharacter(descendant) then
- closestEnemy = humanoid
- closestDistance = distance
- end
- end
- end
- return closestEnemy
- end
- local function continuousTeleport()
- while task.wait() do
- if teleportEnabled then
- local closestEnemy = getClosestEnemy()
- if closestEnemy then
- teleportPlayerBehind(closestEnemy)
- end
- end
- end
- end
- UserInputService.InputBegan:Connect(onKeyPress)
- coroutine.wrap(continuousTeleport)()
- print("Loaded! 0.2")
- end)
- if err then
- warn("//////////////////////////////////////////////////")
- getgenv().autoupgradeerr = true
- --error(err)
- end
- end
- coroutine.resume(coroutine.create(function()
- while task.wait(2) do
- if getgenv().autoupgradeerr == true then
- task.wait()
- autoupgradefunc()
- getgenv().autoupgradeerr = false
- end
- end
- end))
- pcall(function()
- autoupgradefunc()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement