Advertisement
ERROR_CODE

Create

Nov 6th, 2024 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.20 KB | None | 0 0
  1. local UserInputService = game:GetService("UserInputService")
  2. local TweenService = game:GetService("TweenService")
  3.  
  4. local screenGui = Instance.new("ScreenGui")
  5. screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  6.  
  7. local nameTextBox = Instance.new("TextBox")
  8. nameTextBox.Size = UDim2.new(0, 200, 0, 50)
  9. nameTextBox.Position = UDim2.new(0, 10, 0, 10)
  10. nameTextBox.PlaceholderText = "Имя фрейма"
  11. nameTextBox.Parent = screenGui
  12.  
  13. local parentTextBox = Instance.new("TextBox")
  14. parentTextBox.Size = UDim2.new(0, 200, 0, 50)
  15. parentTextBox.Position = UDim2.new(0, 220, 0, 10)
  16. parentTextBox.PlaceholderText = "Имя родителя"
  17. parentTextBox.Parent = screenGui
  18.  
  19. local convertButton = Instance.new("TextButton")
  20. convertButton.Size = UDim2.new(0, 200, 0, 50)
  21. convertButton.Position = UDim2.new(0, 430, 0, 10)
  22. convertButton.Text = "Конвертировать в Lua"
  23. convertButton.Parent = screenGui
  24.  
  25. local function createBlock(blockType, name, parentName)
  26.     local parent = screenGui:FindFirstChild(parentName) or screenGui
  27.     local block = Instance.new(blockType)
  28.     block.Name = name
  29.     block.Size = UDim2.new(0, 100, 0, 50)
  30.     block.Position = UDim2.new(0.5, 0, 0.5, 0)
  31.     block.BackgroundColor3 = Color3.fromRGB(200, 200, 200)
  32.     block.Active = true
  33.     block.Parent = parent
  34.     block.AnchorPoint = Vector2.new(0.5, 0.5)
  35.  
  36.    
  37.     local dragging = false
  38.     local dragInput, mousePos, framePos
  39.  
  40.     block.InputBegan:Connect(function(input)
  41.         if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  42.             dragging = true
  43.             mousePos = input.Position
  44.             framePos = block.Position
  45.  
  46.             input.Changed:Connect(function()
  47.                 if input.UserInputState == Enum.UserInputState.End then
  48.                     dragging = false
  49.                 end
  50.             end)
  51.         end
  52.     end)
  53.  
  54.     block.InputChanged:Connect(function(input)
  55.         if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  56.             dragInput = input
  57.         end
  58.     end)
  59.  
  60.     UserInputService.InputChanged:Connect(function(input)
  61.         if input == dragInput and dragging then
  62.             local delta = input.Position - mousePos
  63.             block.Position = UDim2.new(framePos.X.Scale, framePos.X.Offset + delta.X, framePos.Y.Scale, framePos.Y.Offset + delta.Y)
  64.         end
  65.     end)
  66.  
  67.     local resizeHandle = Instance.new("ImageButton")
  68.     resizeHandle.Size = UDim2.new(0, 30, 0, 30)
  69.     resizeHandle.Position = UDim2.new(1, -10, 1, -10)
  70.     resizeHandle.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  71.     resizeHandle.Image = "rbxassetid://115903044577530" -- Замените на ID вашего изображения
  72.     resizeHandle.Parent = block
  73.  
  74.     local resizing = false
  75.     local resizeInput, resizeMousePos, resizeFrameSize
  76.  
  77.     resizeHandle.InputBegan:Connect(function(input)
  78.         if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  79.             resizing = true
  80.             resizeMousePos = input.Position
  81.             resizeFrameSize = block.Size
  82.  
  83.             input.Changed:Connect(function()
  84.                 if input.UserInputState == Enum.UserInputState.End then
  85.                     resizing = false
  86.                 end
  87.             end)
  88.         end
  89.     end)
  90.  
  91.     resizeHandle.InputChanged:Connect(function(input)
  92.         if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  93.             resizeInput = input
  94.         end
  95.     end)
  96.  
  97.     UserInputService.InputChanged:Connect(function(input)
  98.         if input == resizeInput and resizing then
  99.             local delta = input.Position - resizeMousePos
  100.             block.Size = UDim2.new(resizeFrameSize.X.Scale, resizeFrameSize.X.Offset + delta.X, resizeFrameSize.Y.Scale, resizeFrameSize.Y.Offset + delta.Y)
  101.         end
  102.     end)
  103.  
  104.     local deleteButton = Instance.new("ImageButton")
  105.     deleteButton.Size = UDim2.new(0, 30, 0, 30)
  106.     deleteButton.Position = UDim2.new(1, -20, 0, 0)
  107.     deleteButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  108.     deleteButton.Image = "rbxassetid://81303447485944" -- Замените на ID вашего изображения
  109.     deleteButton.Parent = block
  110.  
  111.     deleteButton.MouseButton1Click:Connect(function()
  112.         block:Destroy()
  113.     end)
  114. end
  115.  
  116. local function createButton(buttonText, blockType)
  117.     local button = Instance.new("TextButton")
  118.     button.Size = UDim2.new(0, 200, 0, 50)
  119.     button.Position = UDim2.new(0, 10, 0, 70 + (#screenGui:GetChildren() - 3) * 60)
  120.     button.Text = buttonText
  121.     button.Parent = screenGui
  122.  
  123.     button.MouseButton1Click:Connect(function()
  124.         local name = nameTextBox.Text
  125.         local parentName = parentTextBox.Text
  126.         createBlock(blockType, name, parentName)
  127.     end)
  128. end
  129.  
  130. createButton("Создать TextButton", "TextButton")
  131. createButton("Создать Frame", "Frame")
  132. createButton("Создать UICorner", "UICorner")
  133.  
  134. local function convertToLua()
  135.     local function serialize(instance)
  136.         local props = {}
  137.         for _, prop in ipairs({"Name", "Size", "Position", "BackgroundColor3", "Parent"}) do
  138.             local success, value = pcall(function() return instance[prop] end)
  139.             if success then
  140.                 if prop == "Parent" then
  141.                     value = value and value.Name or "nil"
  142.                 end
  143.                 table.insert(props, string.format("%s = %s", prop, tostring(value)))
  144.             end
  145.         end
  146.         return string.format("local %s = Instance.new('%s')\n%s\n%s.Parent = %s",
  147.             instance.Name, instance.ClassName, table.concat(props, "\n"), instance.Name, instance.Parent and instance.Parent.Name or "nil")
  148.     end
  149.  
  150.     local code = {}
  151.     for _, child in ipairs(screenGui:GetChildren()) do
  152.         if child:IsA("GuiObject") and child ~= nameTextBox and child ~= parentTextBox and child ~= convertButton then
  153.             table.insert(code, serialize(child))
  154.         end
  155.     end
  156.  
  157.     print(table.concat(code, "\n\n"))
  158. end
  159. convertButton.MouseButton1Click:Connect(convertToLua)
  160.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement