-- LocalScript в StarterPlayerScripts local Players = game:GetService("Players") local Player = Players.LocalPlayer local UserInputService = game:GetService("UserInputService") -- Переменная для хранения сохраненной CFrame local savedCFrame = nil local ScreenGui -- будем пересоздавать -- === ФУНКЦИЯ СОЗДАНИЯ GUI === local function createGui() if ScreenGui then ScreenGui:Destroy() end ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "AutoTeleportGui" ScreenGui.Parent = Player:WaitForChild("PlayerGui") local MainFrame = Instance.new("Frame") MainFrame.Name = "MainFrame" MainFrame.Position = UDim2.new(1, -200, 1, -110) MainFrame.Size = UDim2.new(0, 180, 0, 90) MainFrame.BorderSizePixel = 0 MainFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40) MainFrame.Active = true MainFrame.Parent = ScreenGui local UICorner = Instance.new("UICorner") UICorner.CornerRadius = UDim.new(0, 8) UICorner.Parent = MainFrame local SaveButton = Instance.new("TextButton") SaveButton.Name = "SaveButton" SaveButton.Size = UDim2.new(0.9, 0, 0.4, 0) SaveButton.Position = UDim2.new(0.05, 0, 0.08, 0) SaveButton.Text = "СОХРАНИТЬ" SaveButton.Font = Enum.Font.GothamBold SaveButton.TextSize = 14 SaveButton.TextColor3 = Color3.fromRGB(255, 255, 255) SaveButton.BackgroundColor3 = Color3.fromRGB(70, 130, 180) SaveButton.Parent = MainFrame local UICornerSave = UICorner:Clone() UICornerSave.Parent = SaveButton local TeleportButton = Instance.new("TextButton") TeleportButton.Name = "TeleportButton" TeleportButton.Size = UDim2.new(0.9, 0, 0.4, 0) TeleportButton.Position = UDim2.new(0.05, 0, 0.52, 0) TeleportButton.Text = "ТЕЛЕПОРТ" TeleportButton.Font = Enum.Font.GothamBold TeleportButton.TextSize = 14 TeleportButton.TextColor3 = Color3.fromRGB(255, 255, 255) TeleportButton.BackgroundColor3 = Color3.fromRGB(60, 179, 113) TeleportButton.Parent = MainFrame local UICornerTeleport = UICorner:Clone() UICornerTeleport.Parent = TeleportButton -- === Перетаскивание === local dragging = false local dragOffset = Vector2.new() MainFrame.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then dragging = true local mousePos = UserInputService:GetMouseLocation() dragOffset = mousePos - MainFrame.AbsolutePosition MainFrame:BringToFront() end end) MainFrame.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then dragging = false end end) UserInputService.InputChanged:Connect(function(input) if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then local mousePos = UserInputService:GetMouseLocation() local frameSize = MainFrame.AbsoluteSize local screenSize = workspace.CurrentCamera.ViewportSize local newX = math.clamp(mousePos.X - dragOffset.X, 0, screenSize.X - frameSize.X) local newY = math.clamp(mousePos.Y - dragOffset.Y, 0, screenSize.Y - frameSize.Y) MainFrame.Position = UDim2.fromOffset(newX, newY) end end) -- === Телепортация === local function getRootPart(character) return character and character:FindFirstChild("HumanoidRootPart") end SaveButton.MouseButton1Click:Connect(function() local character = Player.Character or Player.CharacterAdded:Wait() local rootPart = getRootPart(character) if rootPart then savedCFrame = rootPart.CFrame SaveButton.Text = "СОХРАНЕНО!" task.delay(1.5, function() SaveButton.Text = "СОХРАНИТЬ" end) end end) TeleportButton.MouseButton1Click:Connect(function() if savedCFrame then local character = Player.Character or Player.CharacterAdded:Wait() local rootPart = getRootPart(character) if rootPart then rootPart.CFrame = savedCFrame TeleportButton.Text = "ТЕЛЕПОРТ!" task.delay(1.5, function() TeleportButton.Text = "ТЕЛЕПОРТ" end) end else TeleportButton.Text = "НЕТ ПОЗИЦИИ" task.delay(1.5, function() TeleportButton.Text = "ТЕЛЕПОРТ" end) end end) end -- === Пересоздание GUI при респавне === Player.CharacterAdded:Connect(function() createGui() end) -- Первый запуск createGui()