Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local TweenService = game:GetService("TweenService")
- local UserInputService = game:GetService("UserInputService")
- local player = Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local savedPositions = {}
- local buttons = {}
- local dragging = false
- local dragStartPos, frameStartPos
- -- Создаем красивый GUI
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "PositionButtonsGUI"
- screenGui.ResetOnSpawn = false
- screenGui.Parent = player.PlayerGui
- local mainFrame = Instance.new("Frame")
- mainFrame.Size = UDim2.new(0, 350, 0, 340)
- mainFrame.Position = UDim2.new(0.5, -175, 0.5, -170)
- mainFrame.AnchorPoint = Vector2.new(0.5, 0.5)
- mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 40)
- mainFrame.BackgroundTransparency = 0.2
- mainFrame.BorderSizePixel = 0
- mainFrame.ClipsDescendants = true
- mainFrame.Parent = screenGui
- -- Скругленные углы
- local corner = Instance.new("UICorner")
- corner.CornerRadius = UDim.new(0, 12)
- corner.Parent = mainFrame
- -- Тень
- local shadow = Instance.new("ImageLabel")
- shadow.Name = "Shadow"
- shadow.Image = "rbxassetid://1316045217"
- shadow.ImageColor3 = Color3.new(0, 0, 0)
- shadow.ImageTransparency = 0.8
- shadow.ScaleType = Enum.ScaleType.Slice
- shadow.SliceCenter = Rect.new(10, 10, 118, 118)
- shadow.Size = UDim2.new(1, 20, 1, 20)
- shadow.Position = UDim2.new(0, -10, 0, -10)
- shadow.BackgroundTransparency = 1
- shadow.Parent = mainFrame
- -- Заголовок с кнопкой закрытия
- local header = Instance.new("Frame")
- header.Size = UDim2.new(1, 0, 0, 40)
- header.BackgroundColor3 = Color3.fromRGB(45, 45, 60)
- header.BorderSizePixel = 0
- header.Parent = mainFrame
- local headerCorner = Instance.new("UICorner")
- headerCorner.CornerRadius = UDim.new(0, 12)
- headerCorner.Parent = header
- local title = Instance.new("TextLabel")
- title.Text = "Позиции телепортации"
- title.Font = Enum.Font.GothamBold
- title.TextSize = 18
- title.TextColor3 = Color3.new(1, 1, 1)
- title.BackgroundTransparency = 1
- title.Size = UDim2.new(1, -40, 1, 0)
- title.Position = UDim2.new(0, 15, 0, 0)
- title.TextXAlignment = Enum.TextXAlignment.Left
- title.Parent = header
- local closeButton = Instance.new("TextButton")
- closeButton.Text = "×"
- closeButton.Font = Enum.Font.GothamBold
- closeButton.TextSize = 24
- closeButton.TextColor3 = Color3.new(1, 1, 1)
- closeButton.BackgroundTransparency = 1
- closeButton.Size = UDim2.new(0, 40, 1, 0)
- closeButton.Position = UDim2.new(1, -40, 0, 0)
- closeButton.Parent = header
- closeButton.MouseButton1Click:Connect(function()
- screenGui:Destroy()
- end)
- -- Функция для ограничения позиции в пределах экрана
- local function clampPosition(position, frameSize)
- local viewportSize = workspace.CurrentCamera.ViewportSize
- local halfX = frameSize.X.Offset/2
- local halfY = frameSize.Y.Offset/2
- local x = math.clamp(position.X.Offset, halfX, viewportSize.X - halfX)
- local y = math.clamp(position.Y.Offset, halfY, viewportSize.Y - halfY)
- return UDim2.new(0, x, 0, y)
- end
- -- Обновленная функция перемещения с ограничением
- local function updateDrag(input)
- if dragging then
- local delta = input.Position - dragStartPos
- local newPosition = UDim2.new(
- 0, frameStartPos.X.Offset + delta.X,
- 0, frameStartPos.Y.Offset + delta.Y
- )
- mainFrame.Position = clampPosition(newPosition, mainFrame.Size)
- end
- end
- header.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- dragging = true
- dragStartPos = input.Position
- frameStartPos = mainFrame.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end)
- header.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement then
- updateDrag(input)
- end
- end)
- UserInputService.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement then
- updateDrag(input)
- end
- end)
- -- Основной контент
- local contentFrame = Instance.new("Frame")
- contentFrame.Size = UDim2.new(1, -20, 1, -60)
- contentFrame.Position = UDim2.new(0, 10, 0, 50)
- contentFrame.BackgroundTransparency = 1
- contentFrame.Parent = mainFrame
- local uiGridLayout = Instance.new("UIGridLayout")
- uiGridLayout.CellSize = UDim2.new(0, 100, 0, 90)
- uiGridLayout.CellPadding = UDim2.new(0, 10, 0, 10)
- uiGridLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
- uiGridLayout.VerticalAlignment = Enum.VerticalAlignment.Center
- uiGridLayout.Parent = contentFrame
- -- Функция для создания стилизованной кнопки
- local function createButton(name, text, color)
- local button = Instance.new("TextButton")
- button.Name = name
- button.Text = text
- button.Font = Enum.Font.Gotham
- button.TextSize = 14
- button.TextColor3 = Color3.new(1, 1, 1)
- button.BackgroundColor3 = color
- button.Size = UDim2.new(0, 100, 0, 90)
- button.AutoButtonColor = true
- local buttonCorner = Instance.new("UICorner")
- buttonCorner.CornerRadius = UDim.new(0, 8)
- buttonCorner.Parent = button
- local buttonShadow = Instance.new("ImageLabel")
- buttonShadow.Name = "Shadow"
- buttonShadow.Image = "rbxassetid://1316045217"
- buttonShadow.ImageColor3 = Color3.new(0, 0, 0)
- buttonShadow.ImageTransparency = 0.8
- buttonShadow.ScaleType = Enum.ScaleType.Slice
- buttonShadow.SliceCenter = Rect.new(10, 10, 118, 118)
- buttonShadow.Size = UDim2.new(1, 10, 1, 10)
- buttonShadow.Position = UDim2.new(0, -5, 0, -5)
- buttonShadow.BackgroundTransparency = 1
- buttonShadow.Parent = button
- return button
- end
- -- Функция для плавного перемещения
- local function flyToPosition(humanoidRootPart, targetCFrame)
- local tweenInfo = TweenInfo.new(
- 2, -- Длительность полета
- Enum.EasingStyle.Quad,
- Enum.EasingDirection.Out
- )
- local tween = TweenService:Create(
- humanoidRootPart,
- tweenInfo,
- {CFrame = targetCFrame}
- )
- tween:Play()
- return tween
- end
- -- Функция сброса всех позиций
- local function resetAllPositions()
- for i = 1, 6 do
- savedPositions[i] = nil
- if buttons[i] then
- buttons[i].Text = "Позиция "..i
- buttons[i].BackgroundColor3 = Color3.fromRGB(70, 90, 120)
- end
- end
- end
- -- Создаем 6 кнопок для позиций
- for i = 1, 6 do
- local button = createButton("Button"..i, "Позиция "..i, Color3.fromRGB(70, 90, 120))
- button.Parent = contentFrame
- buttons[i] = button
- button.MouseButton1Click:Connect(function()
- if savedPositions[i] then
- -- Летим к сохраненной позиции
- button.Text = "Летим "..i
- button.BackgroundColor3 = Color3.fromRGB(200, 70, 70)
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- local tween = flyToPosition(humanoidRootPart, savedPositions[i])
- tween.Completed:Connect(function()
- button.Text = "Позиция "..i
- button.BackgroundColor3 = Color3.fromRGB(70, 90, 120)
- end)
- else
- -- Сохраняем текущую позицию
- savedPositions[i] = character:WaitForChild("HumanoidRootPart").CFrame
- button.Text = "Сохранено "..i
- button.BackgroundColor3 = Color3.fromRGB(70, 160, 70)
- task.wait(0.5)
- button.Text = "Позиция "..i
- button.BackgroundColor3 = Color3.fromRGB(70, 90, 120)
- end
- end)
- end
- -- Кнопка сброса
- local resetButton = createButton("ResetButton", "Сбросить все", Color3.fromRGB(120, 70, 70))
- resetButton.Size = UDim2.new(1, -20, 0, 40)
- resetButton.Position = UDim2.new(0, 10, 1, -50)
- resetButton.Parent = mainFrame
- resetButton.MouseButton1Click:Connect(function()
- resetAllPositions()
- resetButton.Text = "Сброшено!"
- resetButton.BackgroundColor3 = Color3.fromRGB(70, 160, 70)
- task.wait(0.8)
- resetButton.Text = "Сбросить все"
- resetButton.BackgroundColor3 = Color3.fromRGB(120, 70, 70)
- end)
- -- Обработчик перерождения персонажа
- player.CharacterAdded:Connect(function(newCharacter)
- character = newCharacter
- end)
- -- Обработчик изменения размера экрана
- workspace.CurrentCamera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
- mainFrame.Position = clampPosition(mainFrame.Position, mainFrame.Size)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement