Advertisement
kill21_2

тп к модели gui

May 23rd, 2025
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.47 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local UserInputService = game:GetService("UserInputService")
  3.  
  4. local player = Players.LocalPlayer
  5. local gui = Instance.new("ScreenGui")
  6. gui.Name = "TeleportGUI"
  7. gui.ResetOnSpawn = false
  8. gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  9. gui.Parent = player:WaitForChild("PlayerGui")
  10.  
  11. -- Основной фрейм
  12. local mainFrame = Instance.new("Frame")
  13. mainFrame.Name = "MainFrame"
  14. mainFrame.Size = UDim2.new(0, 350, 0, 250)
  15. mainFrame.Position = UDim2.new(0.5, -175, 0.5, -125)
  16. mainFrame.AnchorPoint = Vector2.new(0.5, 0.5)
  17. mainFrame.BackgroundColor3 = Color3.fromRGB(18, 18, 18)
  18. mainFrame.BorderColor3 = Color3.fromRGB(75, 0, 130)
  19. mainFrame.BorderSizePixel = 2
  20. mainFrame.Parent = gui
  21.  
  22. -- Заголовок
  23. local title = Instance.new("TextLabel")
  24. title.Name = "Title"
  25. title.Size = UDim2.new(1, 0, 0, 40)
  26. title.Position = UDim2.new(0, 0, 0, 0)
  27. title.BackgroundColor3 = Color3.fromRGB(30, 0, 50)
  28. title.BorderSizePixel = 0
  29. title.Text = "OBJECT TELEPORT"
  30. title.TextColor3 = Color3.fromRGB(200, 180, 255)
  31. title.Font = Enum.Font.GothamBold
  32. title.TextSize = 18
  33. title.Parent = mainFrame
  34.  
  35. -- Поле для ввода
  36. local inputBox = Instance.new("TextBox")
  37. inputBox.Name = "InputBox"
  38. inputBox.Size = UDim2.new(0.9, 0, 0, 35)
  39. inputBox.Position = UDim2.new(0.05, 0, 0.2, 0)
  40. inputBox.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  41. inputBox.BorderColor3 = Color3.fromRGB(100, 0, 180)
  42. inputBox.TextColor3 = Color3.fromRGB(220, 220, 220)
  43. inputBox.PlaceholderText = "Введите имя объекта..."
  44. inputBox.Font = Enum.Font.Gotham
  45. inputBox.TextSize = 14
  46. inputBox.Parent = mainFrame
  47.  
  48. -- Кнопка телепортации
  49. local teleportButton = Instance.new("TextButton")
  50. teleportButton.Name = "TeleportButton"
  51. teleportButton.Size = UDim2.new(0.9, 0, 0, 35)
  52. teleportButton.Position = UDim2.new(0.05, 0, 0.4, 0)
  53. teleportButton.BackgroundColor3 = Color3.fromRGB(80, 0, 120)
  54. teleportButton.BorderSizePixel = 0
  55. teleportButton.Text = "ТЕЛЕПОРТИРОВАТЬСЯ"
  56. teleportButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  57. teleportButton.Font = Enum.Font.GothamBold
  58. teleportButton.TextSize = 14
  59. teleportButton.Parent = mainFrame
  60.  
  61. -- Эффект при наведении на кнопку
  62. teleportButton.MouseEnter:Connect(function()
  63. teleportButton.BackgroundColor3 = Color3.fromRGB(120, 0, 180)
  64. end)
  65.  
  66. teleportButton.MouseLeave:Connect(function()
  67. teleportButton.BackgroundColor3 = Color3.fromRGB(80, 0, 120)
  68. end)
  69.  
  70. -- Кнопка копирования скрипта
  71. local copyScriptButton = Instance.new("TextButton")
  72. copyScriptButton.Name = "CopyScriptButton"
  73. copyScriptButton.Size = UDim2.new(0.9, 0, 0, 35)
  74. copyScriptButton.Position = UDim2.new(0.05, 0, 0.55, 0)
  75. copyScriptButton.BackgroundColor3 = Color3.fromRGB(50, 0, 80)
  76. copyScriptButton.BorderSizePixel = 0
  77. copyScriptButton.Text = "КОПИРОВАТЬ СКРИПТ"
  78. copyScriptButton.TextColor3 = Color3.fromRGB(200, 180, 255)
  79. copyScriptButton.Font = Enum.Font.GothamBold
  80. copyScriptButton.TextSize = 14
  81. copyScriptButton.Parent = mainFrame
  82.  
  83. -- Эффект при наведении на кнопку
  84. copyScriptButton.MouseEnter:Connect(function()
  85. copyScriptButton.BackgroundColor3 = Color3.fromRGB(80, 0, 130)
  86. end)
  87.  
  88. copyScriptButton.MouseLeave:Connect(function()
  89. copyScriptButton.BackgroundColor3 = Color3.fromRGB(50, 0, 80)
  90. end)
  91.  
  92. -- Кнопка закрытия
  93. local closeButton = Instance.new("TextButton")
  94. closeButton.Name = "CloseButton"
  95. closeButton.Size = UDim2.new(0, 30, 0, 30)
  96. closeButton.Position = UDim2.new(1, -35, 0, 5)
  97. closeButton.BackgroundColor3 = Color3.fromRGB(200, 0, 0)
  98. closeButton.BorderSizePixel = 0
  99. closeButton.Text = "X"
  100. closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  101. closeButton.Font = Enum.Font.GothamBold
  102. closeButton.TextSize = 16
  103. closeButton.Parent = mainFrame
  104.  
  105. -- Эффект при наведении на кнопку
  106. closeButton.MouseEnter:Connect(function()
  107. closeButton.BackgroundColor3 = Color3.fromRGB(255, 50, 50)
  108. end)
  109.  
  110. closeButton.MouseLeave:Connect(function()
  111. closeButton.BackgroundColor3 = Color3.fromRGB(200, 0, 0)
  112. end)
  113.  
  114. -- Функция телепортации к объекту
  115. local function teleportToObject(objectName)
  116. local character = player.Character or player.CharacterAdded:Wait()
  117. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  118.  
  119. for _, obj in ipairs(workspace:GetDescendants()) do
  120. if obj.Name == objectName then
  121. -- Если объект имеет позицию (BasePart)
  122. if obj:IsA("BasePart") then
  123. humanoidRootPart.CFrame = obj.CFrame + Vector3.new(0, 3, 0)
  124. return true
  125. -- Если это модель, используем PrimaryPart или первый найденный BasePart
  126. elseif obj:IsA("Model") then
  127. local targetPart = obj.PrimaryPart or obj:FindFirstChildWhichIsA("BasePart")
  128. if targetPart then
  129. humanoidRootPart.CFrame = targetPart.CFrame + Vector3.new(0, 3, 0)
  130. return true
  131. end
  132. end
  133. end
  134. end
  135. return false
  136. end
  137.  
  138. -- Функционал кнопок
  139. teleportButton.MouseButton1Click:Connect(function()
  140. local objectName = inputBox.Text
  141. if objectName == "" then
  142. game:GetService("StarterGui"):SetCore("SendNotification", {
  143. Title = "Ошибка",
  144. Text = "Введите имя объекта!",
  145. Duration = 3
  146. })
  147. return
  148. end
  149.  
  150. local success = teleportToObject(objectName)
  151.  
  152. if success then
  153. game:GetService("StarterGui"):SetCore("SendNotification", {
  154. Title = "Успешно",
  155. Text = "Телепортирован к '"..objectName.."'",
  156. Duration = 3
  157. })
  158. else
  159. game:GetService("StarterGui"):SetCore("SendNotification", {
  160. Title = "Ошибка",
  161. Text = "Объект '"..objectName.."' не найден!",
  162. Duration = 3
  163. })
  164. end
  165. end)
  166.  
  167. copyScriptButton.MouseButton1Click:Connect(function()
  168. local objectName = inputBox.Text
  169. if objectName == "" then
  170. game:GetService("StarterGui"):SetCore("SendNotification", {
  171. Title = "Ошибка",
  172. Text = "Сначала введите имя объекта!",
  173. Duration = 3
  174. })
  175. return
  176. end
  177.  
  178. local scriptToCopy = [[
  179. -- Скрипт для телепортации к объекту: ]]..objectName..[[
  180.  
  181. local Players = game:GetService("Players")
  182. local player = Players.LocalPlayer
  183.  
  184. local function teleportToObject(objName)
  185. local character = player.Character or player.CharacterAdded:Wait()
  186. local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
  187.  
  188. for _, obj in ipairs(workspace:GetDescendants()) do
  189. if obj.Name == "]]..objectName..[[" then
  190. -- Для BasePart
  191. if obj:IsA("BasePart") then
  192. humanoidRootPart.CFrame = obj.CFrame + Vector3.new(0, 3, 0)
  193. return true
  194. -- Для Model
  195. elseif obj:IsA("Model") then
  196. local targetPart = obj.PrimaryPart or obj:FindFirstChildWhichIsA("BasePart")
  197. if targetPart then
  198. humanoidRootPart.CFrame = targetPart.CFrame + Vector3.new(0, 3, 0)
  199. return true
  200. end
  201. end
  202. end
  203. end
  204. return false
  205. end
  206.  
  207. -- Вызов функции телепортации
  208. local success = teleportToObject("]]..objectName..[[")
  209.  
  210. if success then
  211. print("Успешно телепортирован к ']]..objectName..[['")
  212. else
  213. warn("Объект ']]..objectName..[[' не найден!")
  214. end
  215. ]]
  216.  
  217. setclipboard(scriptToCopy)
  218.  
  219. game:GetService("StarterGui"):SetCore("SendNotification", {
  220. Title = "Скрипт скопирован",
  221. Text = "Скрипт телепортации для '"..objectName.."' в буфере",
  222. Duration = 3
  223. })
  224. end)
  225.  
  226. closeButton.MouseButton1Click:Connect(function()
  227. gui:Destroy()
  228. end)
  229.  
  230. -- Функционал перемещения окна
  231. local dragging
  232. local dragInput
  233. local dragStart
  234. local startPos
  235.  
  236. local function update(input)
  237. local delta = input.Position - dragStart
  238. mainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  239. end
  240.  
  241. title.InputBegan:Connect(function(input)
  242. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  243. dragging = true
  244. dragStart = input.Position
  245. startPos = mainFrame.Position
  246.  
  247. input.Changed:Connect(function()
  248. if input.UserInputState == Enum.UserInputState.End then
  249. dragging = false
  250. end
  251. end)
  252. end
  253. end)
  254.  
  255. title.InputChanged:Connect(function(input)
  256. if input.UserInputType == Enum.UserInputType.MouseMovement then
  257. dragInput = input
  258. end
  259. end)
  260.  
  261. UserInputService.InputChanged:Connect(function(input)
  262. if input == dragInput and dragging then
  263. update(input)
  264. end
  265. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement