Advertisement
kill21_2

Позиции Телепортации

Apr 26th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.03 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local TweenService = game:GetService("TweenService")
  3. local UserInputService = game:GetService("UserInputService")
  4. local player = Players.LocalPlayer
  5. local character = player.Character or player.CharacterAdded:Wait()
  6.  
  7. local savedPositions = {}
  8. local buttons = {}
  9. local dragging = false
  10. local dragStartPos, frameStartPos
  11.  
  12. -- Создаем красивый GUI
  13. local screenGui = Instance.new("ScreenGui")
  14. screenGui.Name = "PositionButtonsGUI"
  15. screenGui.ResetOnSpawn = false
  16. screenGui.Parent = player.PlayerGui
  17.  
  18. local mainFrame = Instance.new("Frame")
  19. mainFrame.Size = UDim2.new(0, 350, 0, 340)
  20. mainFrame.Position = UDim2.new(0.5, -175, 0.5, -170)
  21. mainFrame.AnchorPoint = Vector2.new(0.5, 0.5)
  22. mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 40)
  23. mainFrame.BackgroundTransparency = 0.2
  24. mainFrame.BorderSizePixel = 0
  25. mainFrame.ClipsDescendants = true
  26. mainFrame.Parent = screenGui
  27.  
  28. -- Скругленные углы
  29. local corner = Instance.new("UICorner")
  30. corner.CornerRadius = UDim.new(0, 12)
  31. corner.Parent = mainFrame
  32.  
  33. -- Тень
  34. local shadow = Instance.new("ImageLabel")
  35. shadow.Name = "Shadow"
  36. shadow.Image = "rbxassetid://1316045217"
  37. shadow.ImageColor3 = Color3.new(0, 0, 0)
  38. shadow.ImageTransparency = 0.8
  39. shadow.ScaleType = Enum.ScaleType.Slice
  40. shadow.SliceCenter = Rect.new(10, 10, 118, 118)
  41. shadow.Size = UDim2.new(1, 20, 1, 20)
  42. shadow.Position = UDim2.new(0, -10, 0, -10)
  43. shadow.BackgroundTransparency = 1
  44. shadow.Parent = mainFrame
  45.  
  46. -- Заголовок с кнопкой закрытия
  47. local header = Instance.new("Frame")
  48. header.Size = UDim2.new(1, 0, 0, 40)
  49. header.BackgroundColor3 = Color3.fromRGB(45, 45, 60)
  50. header.BorderSizePixel = 0
  51. header.Parent = mainFrame
  52.  
  53. local headerCorner = Instance.new("UICorner")
  54. headerCorner.CornerRadius = UDim.new(0, 12)
  55. headerCorner.Parent = header
  56.  
  57. local title = Instance.new("TextLabel")
  58. title.Text = "Позиции телепортации"
  59. title.Font = Enum.Font.GothamBold
  60. title.TextSize = 18
  61. title.TextColor3 = Color3.new(1, 1, 1)
  62. title.BackgroundTransparency = 1
  63. title.Size = UDim2.new(1, -40, 1, 0)
  64. title.Position = UDim2.new(0, 15, 0, 0)
  65. title.TextXAlignment = Enum.TextXAlignment.Left
  66. title.Parent = header
  67.  
  68. local closeButton = Instance.new("TextButton")
  69. closeButton.Text = "×"
  70. closeButton.Font = Enum.Font.GothamBold
  71. closeButton.TextSize = 24
  72. closeButton.TextColor3 = Color3.new(1, 1, 1)
  73. closeButton.BackgroundTransparency = 1
  74. closeButton.Size = UDim2.new(0, 40, 1, 0)
  75. closeButton.Position = UDim2.new(1, -40, 0, 0)
  76. closeButton.Parent = header
  77.  
  78. closeButton.MouseButton1Click:Connect(function()
  79. screenGui:Destroy()
  80. end)
  81.  
  82. -- Функция для ограничения позиции в пределах экрана
  83. local function clampPosition(position, frameSize)
  84. local viewportSize = workspace.CurrentCamera.ViewportSize
  85. local halfX = frameSize.X.Offset/2
  86. local halfY = frameSize.Y.Offset/2
  87.  
  88. local x = math.clamp(position.X.Offset, halfX, viewportSize.X - halfX)
  89. local y = math.clamp(position.Y.Offset, halfY, viewportSize.Y - halfY)
  90.  
  91. return UDim2.new(0, x, 0, y)
  92. end
  93.  
  94. -- Обновленная функция перемещения с ограничением
  95. local function updateDrag(input)
  96. if dragging then
  97. local delta = input.Position - dragStartPos
  98. local newPosition = UDim2.new(
  99. 0, frameStartPos.X.Offset + delta.X,
  100. 0, frameStartPos.Y.Offset + delta.Y
  101. )
  102. mainFrame.Position = clampPosition(newPosition, mainFrame.Size)
  103. end
  104. end
  105.  
  106. header.InputBegan:Connect(function(input)
  107. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  108. dragging = true
  109. dragStartPos = input.Position
  110. frameStartPos = mainFrame.Position
  111. input.Changed:Connect(function()
  112. if input.UserInputState == Enum.UserInputState.End then
  113. dragging = false
  114. end
  115. end)
  116. end
  117. end)
  118.  
  119. header.InputChanged:Connect(function(input)
  120. if input.UserInputType == Enum.UserInputType.MouseMovement then
  121. updateDrag(input)
  122. end
  123. end)
  124.  
  125. UserInputService.InputChanged:Connect(function(input)
  126. if input.UserInputType == Enum.UserInputType.MouseMovement then
  127. updateDrag(input)
  128. end
  129. end)
  130.  
  131. -- Основной контент
  132. local contentFrame = Instance.new("Frame")
  133. contentFrame.Size = UDim2.new(1, -20, 1, -60)
  134. contentFrame.Position = UDim2.new(0, 10, 0, 50)
  135. contentFrame.BackgroundTransparency = 1
  136. contentFrame.Parent = mainFrame
  137.  
  138. local uiGridLayout = Instance.new("UIGridLayout")
  139. uiGridLayout.CellSize = UDim2.new(0, 100, 0, 90)
  140. uiGridLayout.CellPadding = UDim2.new(0, 10, 0, 10)
  141. uiGridLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  142. uiGridLayout.VerticalAlignment = Enum.VerticalAlignment.Center
  143. uiGridLayout.Parent = contentFrame
  144.  
  145. -- Функция для создания стилизованной кнопки
  146. local function createButton(name, text, color)
  147. local button = Instance.new("TextButton")
  148. button.Name = name
  149. button.Text = text
  150. button.Font = Enum.Font.Gotham
  151. button.TextSize = 14
  152. button.TextColor3 = Color3.new(1, 1, 1)
  153. button.BackgroundColor3 = color
  154. button.Size = UDim2.new(0, 100, 0, 90)
  155. button.AutoButtonColor = true
  156.  
  157. local buttonCorner = Instance.new("UICorner")
  158. buttonCorner.CornerRadius = UDim.new(0, 8)
  159. buttonCorner.Parent = button
  160.  
  161. local buttonShadow = Instance.new("ImageLabel")
  162. buttonShadow.Name = "Shadow"
  163. buttonShadow.Image = "rbxassetid://1316045217"
  164. buttonShadow.ImageColor3 = Color3.new(0, 0, 0)
  165. buttonShadow.ImageTransparency = 0.8
  166. buttonShadow.ScaleType = Enum.ScaleType.Slice
  167. buttonShadow.SliceCenter = Rect.new(10, 10, 118, 118)
  168. buttonShadow.Size = UDim2.new(1, 10, 1, 10)
  169. buttonShadow.Position = UDim2.new(0, -5, 0, -5)
  170. buttonShadow.BackgroundTransparency = 1
  171. buttonShadow.Parent = button
  172.  
  173. return button
  174. end
  175.  
  176. -- Функция для плавного перемещения
  177. local function flyToPosition(humanoidRootPart, targetCFrame)
  178. local tweenInfo = TweenInfo.new(
  179. 2, -- Длительность полета
  180. Enum.EasingStyle.Quad,
  181. Enum.EasingDirection.Out
  182. )
  183.  
  184. local tween = TweenService:Create(
  185. humanoidRootPart,
  186. tweenInfo,
  187. {CFrame = targetCFrame}
  188. )
  189.  
  190. tween:Play()
  191. return tween
  192. end
  193.  
  194. -- Функция сброса всех позиций
  195. local function resetAllPositions()
  196. for i = 1, 6 do
  197. savedPositions[i] = nil
  198. if buttons[i] then
  199. buttons[i].Text = "Позиция "..i
  200. buttons[i].BackgroundColor3 = Color3.fromRGB(70, 90, 120)
  201. end
  202. end
  203. end
  204.  
  205. -- Создаем 6 кнопок для позиций
  206. for i = 1, 6 do
  207. local button = createButton("Button"..i, "Позиция "..i, Color3.fromRGB(70, 90, 120))
  208. button.Parent = contentFrame
  209. buttons[i] = button
  210.  
  211. button.MouseButton1Click:Connect(function()
  212. if savedPositions[i] then
  213. -- Летим к сохраненной позиции
  214. button.Text = "Летим "..i
  215. button.BackgroundColor3 = Color3.fromRGB(200, 70, 70)
  216.  
  217. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  218. local tween = flyToPosition(humanoidRootPart, savedPositions[i])
  219.  
  220. tween.Completed:Connect(function()
  221. button.Text = "Позиция "..i
  222. button.BackgroundColor3 = Color3.fromRGB(70, 90, 120)
  223. end)
  224. else
  225. -- Сохраняем текущую позицию
  226. savedPositions[i] = character:WaitForChild("HumanoidRootPart").CFrame
  227. button.Text = "Сохранено "..i
  228. button.BackgroundColor3 = Color3.fromRGB(70, 160, 70)
  229.  
  230. task.wait(0.5)
  231. button.Text = "Позиция "..i
  232. button.BackgroundColor3 = Color3.fromRGB(70, 90, 120)
  233. end
  234. end)
  235. end
  236.  
  237. -- Кнопка сброса
  238. local resetButton = createButton("ResetButton", "Сбросить все", Color3.fromRGB(120, 70, 70))
  239. resetButton.Size = UDim2.new(1, -20, 0, 40)
  240. resetButton.Position = UDim2.new(0, 10, 1, -50)
  241. resetButton.Parent = mainFrame
  242.  
  243. resetButton.MouseButton1Click:Connect(function()
  244. resetAllPositions()
  245. resetButton.Text = "Сброшено!"
  246. resetButton.BackgroundColor3 = Color3.fromRGB(70, 160, 70)
  247.  
  248. task.wait(0.8)
  249. resetButton.Text = "Сбросить все"
  250. resetButton.BackgroundColor3 = Color3.fromRGB(120, 70, 70)
  251. end)
  252.  
  253. -- Обработчик перерождения персонажа
  254. player.CharacterAdded:Connect(function(newCharacter)
  255. character = newCharacter
  256. end)
  257.  
  258. -- Обработчик изменения размера экрана
  259. workspace.CurrentCamera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
  260. mainFrame.Position = clampPosition(mainFrame.Position, mainFrame.Size)
  261. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement