Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Сохраняем ссылку на основной скрипт в глобальной переменной
- if not _G.TeleportScript then
- _G.TeleportScript = coroutine.create(function()
- -- Настройки
- local initialPosition = Vector3.new(-1010.22, 328.23, 4.06)
- local teleportDelay = 2
- local heightOffset = 3
- local respawnDelay = 1
- local maxRespawnWaitTime = 10
- -- Функция для отладки
- local function debugPrint(...)
- print("[Teleport ON]", os.date("%X"), ...)
- end
- -- Надежная функция ожидания возрождения
- local function waitForRespawn()
- debugPrint("Инициируем смерть персонажа")
- local char = game.Players.LocalPlayer.Character
- if char then
- local humanoid = char:FindFirstChildOfClass("Humanoid")
- if humanoid then
- humanoid.Health = 0
- else
- char:BreakJoints()
- end
- end
- debugPrint("Ожидаем возрождения...")
- local startTime = tick()
- local newChar
- repeat
- wait(0.5)
- newChar = game.Players.LocalPlayer.Character
- if tick() - startTime > maxRespawnWaitTime then
- debugPrint("Таймаут ожидания возрождения!")
- return false
- end
- until newChar and newChar.PrimaryPart and newChar:FindFirstChildOfClass("Humanoid") and newChar:FindFirstChildOfClass("Humanoid").Health > 0
- debugPrint("Персонаж успешно возродился")
- wait(respawnDelay)
- return true
- end
- -- Основной рабочий цикл
- while _G.TeleportScriptRunning do
- debugPrint("\n=== НАЧАЛО НОВОГО ЦИКЛА ===")
- -- Ожидаем готовность персонажа
- while _G.TeleportScriptRunning and (not game.Players.LocalPlayer.Character or not game.Players.LocalPlayer.Character.PrimaryPart) do
- wait(0.5)
- end
- if not _G.TeleportScriptRunning then break end
- -- Телепорт к начальной позиции
- debugPrint("Телепорт к начальной позиции")
- game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(CFrame.new(initialPosition))
- wait(teleportDelay)
- -- Телепорт к объектам
- local slapples = workspace:FindFirstChild("Arena") and
- workspace.Arena:FindFirstChild("island5") and
- workspace.Arena.island5:FindFirstChild("Slapples")
- if slapples then
- for _, obj in ipairs(slapples:GetChildren()) do
- if not _G.TeleportScriptRunning then break end
- local targetPart = obj:IsA("BasePart") and obj or
- (obj:IsA("Model") and (obj.PrimaryPart or obj:FindFirstChildWhichIsA("BasePart")))
- if targetPart then
- debugPrint("Телепорт к "..obj.Name)
- local targetPos = targetPart.Position + Vector3.new(0, heightOffset, 0)
- game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(CFrame.new(targetPos))
- wait(teleportDelay)
- end
- end
- else
- debugPrint("Папка Slapples не найдена!")
- end
- if _G.TeleportScriptRunning and not waitForRespawn() then
- debugPrint("Проблема с возрождением, пробуем снова...")
- wait(3)
- end
- end
- debugPrint("Телепортация остановлена")
- end)
- end
- -- Запускаем скрипт
- _G.TeleportScriptRunning = true
- coroutine.resume(_G.TeleportScript)
- print("Телепортация АКТИВИРОВАНА (Ctrl+F8 для выключения)")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement