Advertisement
NCXKayy

Menu

Jun 1st, 2025
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.32 KB | Source Code | 0 0
  1. local player = game.Players.LocalPlayer
  2. local screenGui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
  3. local userInputService = game:GetService("UserInputService")
  4. local tweenService = game:GetService("TweenService")
  5.  
  6. --=================================
  7. -- 🔹 PHẦN 1: TẠO MENU + NÚT ẨN/HIỆN
  8. --=================================
  9. local menuFrame = Instance.new("Frame", screenGui)
  10. menuFrame.Size = UDim2.new(0, 250, 0, 170)
  11. menuFrame.BackgroundTransparency = 1
  12. menuFrame.Position = UDim2.new(0.5, -125, 0.5, -85)
  13. menuFrame.Visible = false
  14. menuFrame.ZIndex = 1
  15.  
  16. -- Nút Ẩn/Hiện
  17. local toggleButton = Instance.new("TextButton", screenGui)
  18. toggleButton.Size = UDim2.new(0, 50, 0, 50) -- Hình vuông
  19. toggleButton.Position = UDim2.new(0, 50, 0, 50)
  20. toggleButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0) -- Màu đen
  21. toggleButton.Text = "" -- Bỏ chữ
  22.  
  23. -- Thêm hình troll face
  24. local trollFaceImage = Instance.new("ImageLabel", toggleButton)
  25. trollFaceImage.Size = UDim2.new(1.2, 0, 1.2, 0) -- Lớn hơn nút một chút
  26. trollFaceImage.Position = UDim2.new(-0.1, 0, -0.1, 0) -- Dịch ra ngoài viền nút
  27. trollFaceImage.Image = "rbxassetid://12345678" -- Thay thế bằng ID chính xác
  28. trollFaceImage.BackgroundTransparency = 1
  29. trollFaceImage.BorderSizePixel = 0
  30.  
  31. --=================================
  32. -- 🔹 PHẦN 2: TẠO FRAME KÉO ĐÈ LÊN MENU
  33. --=================================
  34. local dragFrame = Instance.new("ScrollingFrame", menuFrame)
  35. dragFrame.Size = UDim2.new(0.98, 0, 0.98, 0)
  36. dragFrame.Position = UDim2.new(0.010, 0, 0.010, 0)
  37. dragFrame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  38. dragFrame.BackgroundTransparency = 0
  39. dragFrame.BorderSizePixel = 0
  40. dragFrame.ZIndex = 2
  41. dragFrame.CanvasSize = UDim2.new(0, 0, 2, 0) -- Cho phép kéo nội dung xuống
  42. dragFrame.ScrollBarThickness = 5 -- Độ dày thanh cuộn
  43. dragFrame.ScrollBarImageColor3 = Color3.fromRGB(255, 255, 255) -- Màu thanh cuộn
  44.  
  45.  
  46. local isDraggingMenu = false
  47. local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
  48.  
  49. dragFrame.InputBegan:Connect(function(input)
  50.     -- Không cho phép kéo nếu đang tương tác với dragFrame
  51.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  52.         isDraggingMenu = false
  53.     end
  54. end)
  55.  
  56.  
  57. userInputService.InputChanged:Connect(function(movingInput)
  58.     if isDraggingMenu and movingInput.UserInputType == Enum.UserInputType.MouseMovement then
  59.         local targetPosition = UDim2.new(0, movingInput.Position.X - menuFrame.Size.X.Offset / 2, 0, movingInput.Position.Y - dragFrame.Size.Y.Offset / 2)
  60.         local tween = tweenService:Create(menuFrame, tweenInfo, {Position = targetPosition})
  61.         tween:Play()
  62.     end
  63. end)
  64.  
  65. dragFrame.InputEnded:Connect(function(input)
  66.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  67.         isDraggingMenu = false
  68.     end
  69. end)
  70.  
  71. --=================================
  72. -- 🔹 PHẦN 3: HIỆU ỨNG RGB (TOÀN MENU)
  73. --=================================
  74. local uiGradient = Instance.new("UIGradient", menuFrame)
  75. uiGradient.Rotation = 0
  76. uiGradient.Color = ColorSequence.new({
  77.     ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 0, 0)),
  78.     ColorSequenceKeypoint.new(0.2, Color3.fromRGB(255, 255, 0)),
  79.     ColorSequenceKeypoint.new(0.4, Color3.fromRGB(0, 255, 0)),
  80.     ColorSequenceKeypoint.new(0.6, Color3.fromRGB(0, 255, 255)),
  81.     ColorSequenceKeypoint.new(0.8, Color3.fromRGB(255, 0, 255)),
  82.     ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 0, 0))
  83. })
  84.  
  85. local stroke = Instance.new("UIStroke", menuFrame)
  86. stroke.Thickness = 5
  87. stroke.Color = Color3.fromRGB(0, 0, 0)
  88. stroke.Transparency = 0.5
  89.  
  90. task.spawn(function()
  91.     while true do
  92.         for i = 0, 360, 8 do
  93.             uiGradient.Rotation = i
  94.             task.wait(0.02)
  95.         end
  96.     end
  97. end)
  98. --=================================
  99. -- 🔹 PHẦN 4: CHỨC NĂNG TRONG DRAGFRAME (MỞ RỘNG MƯỢT + HIỂN THỊ CẤP)
  100. --=================================
  101.  
  102. --=================================
  103. -- 🔹 PHẦN 5: CHỨC NĂNG MENU (ẨN/HIỆN + CẬP NHẬT VỊ TRÍ)
  104. --=================================
  105. local function updateMenuPosition()
  106.     menuFrame.Position = toggleButton.Position + UDim2.new(0, toggleButton.Size.X.Offset + 15, 0, 0)
  107. end
  108.  
  109. local isDragging = false
  110.  
  111. toggleButton.InputBegan:Connect(function(input)
  112.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  113.         isDragging = true
  114.     end
  115. end)
  116.  
  117. userInputService.InputChanged:Connect(function(movingInput)
  118.     if isDragging and movingInput.UserInputType == Enum.UserInputType.MouseMovement then
  119.         toggleButton.Position = UDim2.new(0, movingInput.Position.X, 0, movingInput.Position.Y)
  120.         updateMenuPosition()
  121.     end
  122. end)
  123.  
  124. toggleButton.InputEnded:Connect(function(input)
  125.     if input.UserInputType == Enum.UserInputType.MouseButton1 then
  126.         isDragging = false
  127.     end
  128. end)
  129.  
  130. local function toggleMenu()
  131.     local isVisible = not menuFrame.Visible
  132.     local tweenTime = 0.25 -- Chỉnh thời gian ẩn/hiện menu
  133.     local tweenInfo = TweenInfo.new(tweenTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  134.     local tween = tweenService:Create(menuFrame, tweenInfo, {BackgroundTransparency = isVisible and 0 or 1})
  135.  
  136.     if isVisible then
  137.         updateMenuPosition()
  138.         menuFrame.Visible = true
  139.         tween:Play()
  140.     else
  141.         tween:Play()
  142.         tween.Completed:Connect(function()
  143.             menuFrame.Visible = false
  144.         end)
  145.     end
  146. end
  147.  
  148. toggleButton.MouseButton1Click:Connect(toggleMenu)
  149.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement