Advertisement
Jsjdbot

Xd

Nov 21st, 2024 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.57 KB | None | 0 0
  1. local UILibrary = {}
  2. UILibrary.__index = UILibrary
  3.  
  4. function UILibrary.new(title)
  5. local self = setmetatable({}, UILibrary)
  6.  
  7. local existingGui = game:GetService("CoreGui"):FindFirstChild("UILibrary")
  8. if existingGui then
  9. existingGui:Destroy()
  10. end
  11.  
  12. self.screenGui = Instance.new("ScreenGui")
  13. self.screenGui.Name = "UILibrary"
  14. self.screenGui.Parent = game:GetService("CoreGui")
  15.  
  16. self.mainFrame = Instance.new("Frame")
  17. self.mainFrame.Parent = self.screenGui
  18. self.mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  19. self.mainFrame.Size = UDim2.new(0, 600, 0, 360)
  20. self.mainFrame.Position = UDim2.new(0.5, -295, 0.5, -211)
  21. self.mainFrame.BorderSizePixel = 0
  22. self.mainFrame.BackgroundTransparency = 0
  23.  
  24. self.titleBar = Instance.new("TextLabel")
  25. self.titleBar.Parent = self.mainFrame
  26. self.titleBar.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  27. self.titleBar.Size = UDim2.new(1, 0, 0, 30)
  28. self.titleBar.Text = title or ""
  29. self.titleBar.TextColor3 = Color3.fromRGB(255, 255, 255)
  30. self.titleBar.Font = Enum.Font.SourceSans
  31. self.titleBar.TextSize = 20
  32. self.titleBar.BorderSizePixel = 0
  33. self.titleBar.BackgroundTransparency = 0
  34.  
  35. self.closeButton = Instance.new("TextButton")
  36. self.closeButton.Parent = self.titleBar
  37. self.closeButton.Text = "X"
  38. self.closeButton.Size = UDim2.new(0, 30, 1, 0)
  39. self.closeButton.Position = UDim2.new(1, -30, 0, 0)
  40. self.closeButton.BorderSizePixel = 0
  41. self.closeButton.Font = Enum.Font.SourceSans
  42. self.closeButton.TextSize = 20
  43. self.closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  44. self.closeButton.BackgroundTransparency = 1
  45.  
  46. self.closeButton.MouseButton1Click:Connect(function()
  47. self:Destroy()
  48. end)
  49.  
  50. self.minimizeButton = Instance.new("TextButton")
  51. self.minimizeButton.Parent = self.titleBar
  52. self.minimizeButton.Text = "-"
  53. self.minimizeButton.Size = UDim2.new(0, 30, 1, 0)
  54. self.minimizeButton.Position = UDim2.new(1, -60, 0, 0)
  55. self.minimizeButton.BorderSizePixel = 0
  56. self.minimizeButton.Font = Enum.Font.SourceSans
  57. self.minimizeButton.TextSize = 20
  58. self.minimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  59. self.minimizeButton.BackgroundTransparency = 1
  60.  
  61. self.isMinimized = false
  62.  
  63. self.minimizeButton.MouseButton1Click:Connect(function()
  64. if self.isMinimized then
  65. self.mainFrame.Size = UDim2.new(0, 600, 0, 360)
  66. self.isMinimized = false
  67. else
  68. self.mainFrame.Size = UDim2.new(0, 600, 0, 30)
  69. self.isMinimized = true
  70. end
  71. end)
  72.  
  73. self.tabFrame = Instance.new("Frame")
  74. self.tabFrame.Parent = self.mainFrame
  75. self.tabFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  76. self.tabFrame.Size = UDim2.new(0, 150, 1, -30)
  77. self.tabFrame.Position = UDim2.new(0, 0, 0, 30)
  78. self.tabFrame.BorderSizePixel = 0
  79.  
  80. local tabLayout = Instance.new("UIListLayout", self.tabFrame)
  81. tabLayout.Padding = UDim.new(0, 5)
  82. tabLayout.SortOrder = Enum.SortOrder.LayoutOrder
  83.  
  84. self.contentFrame = Instance.new("Frame")
  85. self.contentFrame.Parent = self.mainFrame
  86. self.contentFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
  87. self.contentFrame.Size = UDim2.new(1, -150, 1, -30)
  88. self.contentFrame.Position = UDim2.new(0, 150, 0, 30)
  89. self.contentFrame.BorderSizePixel = 0
  90.  
  91. local contentLayout = Instance.new("UIListLayout", self.contentFrame)
  92. contentLayout.Padding = UDim.new(0, 10)
  93. contentLayout.SortOrder = Enum.SortOrder.LayoutOrder
  94.  
  95. local TweenService = game:GetService("TweenService")
  96. local dragging = false
  97. local dragStart = nil
  98. local startPos = nil
  99.  
  100. local function smoothMove(frame, targetPosition)
  101. local tween = TweenService:Create(
  102. frame,
  103. TweenInfo.new(0.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
  104. {Position = targetPosition}
  105. )
  106. tween:Play()
  107. end
  108.  
  109. local function update(input)
  110. local delta = input.Position - dragStart
  111. local newPos = UDim2.new(
  112. startPos.X.Scale,
  113. startPos.X.Offset + delta.X,
  114. startPos.Y.Scale,
  115. startPos.Y.Offset + delta.Y
  116. )
  117. smoothMove(self.mainFrame, newPos)
  118. end
  119.  
  120. self.titleBar.InputBegan:Connect(function(input)
  121. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  122. dragging = true
  123. dragStart = input.Position
  124. startPos = self.mainFrame.Position
  125.  
  126. input.Changed:Connect(function()
  127. if input.UserInputState == Enum.UserInputState.End then
  128. dragging = false
  129. end
  130. end)
  131. end
  132. end)
  133.  
  134. self.titleBar.InputChanged:Connect(function(input)
  135. if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  136. if dragging then
  137. update(input)
  138. end
  139. end
  140. end)
  141.  
  142. game:GetService("UserInputService").InputChanged:Connect(function(input)
  143. if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
  144. update(input)
  145. end
  146. end)
  147.  
  148. return self
  149. end
  150.  
  151. function UILibrary:Destroy()
  152. if self.screenGui then
  153. self.screenGui:Destroy()
  154. end
  155. end
  156.  
  157. function UILibrary:CreateTab(tabName)
  158. local button = Instance.new("TextButton")
  159. button.Parent = self.tabFrame
  160. button.Text = tabName
  161. button.Size = UDim2.new(1, -10, 0, 40)
  162. button.Position = UDim2.new(0, 5, 0, 0)
  163. button.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  164. button.TextColor3 = Color3.fromRGB(255, 255, 255)
  165. button.Font = Enum.Font.SourceSans
  166. button.TextSize = 18
  167.  
  168. local tabContent = Instance.new("Frame")
  169. tabContent.Name = tabName
  170. tabContent.Visible = false
  171. tabContent.Size = UDim2.new(1, 0, 1, 0)
  172. tabContent.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
  173. tabContent.BorderSizePixel = 0
  174. tabContent.Parent = self.contentFrame
  175.  
  176. local layout = Instance.new("UIListLayout", tabContent)
  177. layout.Padding = UDim.new(0, 10)
  178. layout.SortOrder = Enum.SortOrder.LayoutOrder
  179.  
  180. button.MouseButton1Click:Connect(function()
  181. for _, tab in ipairs(self.contentFrame:GetChildren()) do
  182. if tab:IsA("Frame") then
  183. tab.Visible = tab == tabContent
  184. end
  185. end
  186. end)
  187.  
  188. if #self.tabFrame:GetChildren() == 1 then
  189. button.MouseButton1Click:Fire()
  190. end
  191.  
  192. return tabContent
  193. end
  194.  
  195. function UILibrary:CreateButton(parent, text, callback)
  196. local button = Instance.new("TextButton")
  197. button.Parent = parent
  198. button.Text = text
  199. button.Size = UDim2.new(1, 0, 0, 40)
  200. button.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
  201. button.TextColor3 = Color3.fromRGB(255, 255, 255)
  202. button.Font = Enum.Font.SourceSans
  203. button.TextSize = 18
  204. button.BorderSizePixel = 0
  205.  
  206. button.MouseButton1Click:Connect(function()
  207. callback()
  208. end)
  209.  
  210. return button
  211. end
  212.  
  213. function UILibrary:CreateToggle(parent, text, default, callback)
  214. local toggleFrame = Instance.new("Frame", parent)
  215. toggleFrame.Size = UDim2.new(1, -20, 0, 40)
  216. toggleFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  217.  
  218. local toggleLabel = Instance.new("TextLabel", toggleFrame)
  219. toggleLabel.Size = UDim2.new(0, 200, 1, 0)
  220. toggleLabel.Text = text
  221. toggleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  222. toggleLabel.BackgroundTransparency = 1
  223. toggleLabel.TextSize = 18
  224. toggleLabel.Font = Enum.Font.SourceSans
  225.  
  226. local button = Instance.new("TextButton", toggleFrame)
  227. button.Size = UDim2.new(0, 60, 0, 30)
  228. button.Position = UDim2.new(1, -65, 0, 5)
  229. button.Text = default and "ON" or "OFF"
  230. button.BackgroundColor3 = default and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
  231. button.TextColor3 = Color3.fromRGB(255, 255, 255)
  232. button.Font = Enum.Font.SourceSans
  233. button.TextSize = 18
  234.  
  235. button.MouseButton1Click:Connect(function()
  236. default = not default
  237. button.Text = default and "ON" or "OFF"
  238. button.BackgroundColor3 = default and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
  239. if callback then callback(default) end
  240. end)
  241.  
  242. return toggleFrame
  243. end
  244.  
  245. function UILibrary:CreateSlider(parent, text, minValue, maxValue, callback)
  246. local sliderFrame = Instance.new("Frame", parent)
  247. sliderFrame.Size = UDim2.new(1, -20, 0, 40)
  248. sliderFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  249.  
  250. local label = Instance.new("TextLabel", sliderFrame)
  251. label.Text = text
  252. label.Size = UDim2.new(0.4, 0, 1, 0)
  253. label.BackgroundTransparency = 1
  254. label.TextColor3 = Color3.fromRGB(255, 255, 255)
  255. label.Font = Enum.Font.SourceSans
  256. label.TextSize = 18
  257.  
  258. local sliderBar = Instance.new("Frame", sliderFrame)
  259. sliderBar.Size = UDim2.new(0.5, -10, 0, 5)
  260. sliderBar.Position = UDim2.new(0.5, 0, 0.5, -2)
  261. sliderBar.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
  262. sliderBar.BorderSizePixel = 0
  263.  
  264. local sliderThumb = Instance.new("TextButton", sliderBar)
  265. sliderThumb.Size = UDim2.new(0, 20, 1, 0)
  266. sliderThumb.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  267. sliderThumb.Text = ""
  268. sliderThumb.BorderSizePixel = 0
  269.  
  270. local valueLabel = Instance.new("TextLabel", sliderFrame)
  271. valueLabel.Size = UDim2.new(0.2, 0, 1, 0)
  272. valueLabel.Position = UDim2.new(0.8, 0, 0, 0)
  273. valueLabel.BackgroundTransparency = 1
  274. valueLabel.Text = tostring(minValue)
  275. valueLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  276. valueLabel.Font = Enum.Font.SourceSans
  277. valueLabel.TextSize = 18
  278.  
  279. local dragging = false
  280.  
  281. local function updateSlider(input)
  282. if dragging then
  283. local position = math.clamp((input.Position.X - sliderBar.AbsolutePosition.X) / sliderBar.AbsoluteSize.X, 0, 1)
  284. sliderThumb.Position = UDim2.new(position, -10, 0, 0)
  285. local value = math.floor(minValue + (maxValue - minValue) * position)
  286. valueLabel.Text = tostring(value)
  287. if callback then callback(value) end
  288. end
  289. end
  290.  
  291. sliderThumb.MouseButton1Down:Connect(function()
  292. dragging = true
  293. end)
  294.  
  295. game:GetService("UserInputService").InputChanged:Connect(function(input)
  296. if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  297. updateSlider(input)
  298. end
  299. end)
  300.  
  301. game:GetService("UserInputService").InputEnded:Connect(function(input)
  302. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  303. dragging = false
  304. end
  305. end)
  306.  
  307. return sliderFrame
  308. end
  309.  
  310. function UILibrary:CreateDropdown(parent, text, options, callback)
  311. local dropdownFrame = Instance.new("Frame", parent)
  312. dropdownFrame.Size = UDim2.new(1, -20, 0, 40)
  313. dropdownFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  314. dropdownFrame.ZIndex = 2 -- Aseguramos que esté por encima de GUIs básicos
  315.  
  316. local label = Instance.new("TextLabel", dropdownFrame)
  317. label.Text = text
  318. label.Size = UDim2.new(0.7, 0, 1, 0)
  319. label.BackgroundTransparency = 1
  320. label.TextColor3 = Color3.fromRGB(255, 255, 255)
  321. label.Font = Enum.Font.SourceSans
  322. label.TextSize = 18
  323. label.ZIndex = 2 -- También ajustamos el ZIndex de los hijos
  324.  
  325. local button = Instance.new("TextButton", dropdownFrame)
  326. button.Text = "▼"
  327. button.Size = UDim2.new(0.3, 0, 1, 0)
  328. button.Position = UDim2.new(0.7, 0, 0, 0)
  329. button.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  330. button.TextColor3 = Color3.fromRGB(255, 255, 255)
  331. button.Font = Enum.Font.SourceSans
  332. button.TextSize = 18
  333. button.ZIndex = 2
  334.  
  335. local optionsFrame = Instance.new("Frame", dropdownFrame)
  336. optionsFrame.Size = UDim2.new(1, 0, 0, 0)
  337. optionsFrame.Position = UDim2.new(0, 0, 1, 0)
  338. optionsFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
  339. optionsFrame.Visible = false
  340. optionsFrame.ZIndex = 3 -- Aseguramos que esté por encima de dropdownFrame
  341.  
  342. local layout = Instance.new("UIListLayout", optionsFrame)
  343. layout.Padding = UDim.new(0, 5)
  344.  
  345. for _, option in ipairs(options) do
  346. local optionButton = Instance.new("TextButton", optionsFrame)
  347. optionButton.Text = option
  348. optionButton.Size = UDim2.new(1, 0, 0, 30)
  349. optionButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  350. optionButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  351. optionButton.Font = Enum.Font.SourceSans
  352. optionButton.TextSize = 18
  353. optionButton.ZIndex = 3
  354.  
  355. optionButton.MouseButton1Click:Connect(function()
  356. if callback then callback(option) end
  357. optionsFrame.Visible = false
  358. end)
  359. end
  360.  
  361. button.MouseButton1Click:Connect(function()
  362. optionsFrame.Visible = not optionsFrame.Visible
  363. end)
  364.  
  365. return dropdownFrame
  366. end
  367.  
  368. function UILibrary:CreateParagraph(parent, text)
  369. local paragraph = Instance.new("TextLabel")
  370. paragraph.Text = text
  371. paragraph.TextColor3 = Color3.fromRGB(255, 255, 255)
  372. paragraph.Size = UDim2.new(1, -20, 0, 60)
  373. paragraph.BackgroundTransparency = 1
  374. paragraph.TextSize = 18
  375. paragraph.TextWrapped = true
  376. paragraph.TextXAlignment = Enum.TextXAlignment.Left
  377. paragraph.Parent = parent
  378. return paragraph
  379. end
  380.  
  381. function UILibrary:CreateSection(parent, title)
  382. local sectionFrame = Instance.new("Frame")
  383. sectionFrame.Size = UDim2.new(1, 0, 0, 50)
  384. sectionFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  385. sectionFrame.Parent = parent
  386.  
  387. local sectionLabel = Instance.new("TextLabel")
  388. sectionLabel.Text = title
  389. sectionLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  390. sectionLabel.Size = UDim2.new(1, 0, 1, 0)
  391. sectionLabel.BackgroundTransparency = 1
  392. sectionLabel.Font = Enum.Font.SourceSans
  393. sectionLabel.TextSize = 20
  394. sectionLabel.TextXAlignment = Enum.TextXAlignment.Center
  395. sectionLabel.Parent = sectionFrame
  396.  
  397. return sectionFrame
  398. end
  399.  
  400. function UILibrary:ButtonToggle(properties)
  401. local toggleButton = Instance.new("ImageButton")
  402. toggleButton.Image = properties.Image or "rbxassetid://17888450855"
  403. toggleButton.Size = properties.Size or UDim2.new(0, 40, 0, 40)
  404. toggleButton.Position = properties.Position or UDim2.new(0, 10, 0, 10)
  405. toggleButton.BackgroundTransparency = properties.BackgroundTransparency or 1
  406. toggleButton.ImageTransparency = properties.ImageTransparency or 0
  407.  
  408. if properties.CornerRadius then
  409. local corner = Instance.new("UICorner", toggleButton)
  410. corner.CornerRadius = properties.CornerRadius
  411. end
  412.  
  413. toggleButton.Parent = self.screenGui
  414.  
  415. local isVisible = true
  416. local dragging = false
  417. local dragStart, startPos
  418.  
  419. local function startDrag(input)
  420. dragging = true
  421. dragStart = input.Position
  422. startPos = toggleButton.Position
  423. end
  424.  
  425. local function updateDrag(input)
  426. if dragging then
  427. local delta = input.Position - dragStart
  428. toggleButton.Position = UDim2.new(
  429. startPos.X.Scale, startPos.X.Offset + delta.X,
  430. startPos.Y.Scale, startPos.Y.Offset + delta.Y
  431. )
  432. end
  433. end
  434.  
  435. local function endDrag()
  436. dragging = false
  437. end
  438.  
  439. toggleButton.InputBegan:Connect(function(input)
  440. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  441. startDrag(input)
  442. end
  443. end)
  444.  
  445. toggleButton.InputChanged:Connect(function(input)
  446. if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  447. updateDrag(input)
  448. end
  449. end)
  450.  
  451. toggleButton.InputEnded:Connect(function(input)
  452. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  453. endDrag()
  454. end
  455. end)
  456.  
  457. toggleButton.MouseButton1Click:Connect(function()
  458. if not dragging then
  459. isVisible = not isVisible
  460. if self.mainFrame then
  461. self.mainFrame.Visible = isVisible
  462. end
  463. end
  464. end)
  465.  
  466. return toggleButton
  467. end
  468.  
  469. return UILibrary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement