Advertisement
Jsjdbot

Untitled

Jan 23rd, 2025 (edited)
9,274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.26 KB | None | 0 0
  1. local UILibrary = {}
  2.  
  3. local function addCorner(instance, radius)
  4. local corner = Instance.new("UICorner")
  5. corner.CornerRadius = UDim.new(0, radius)
  6. corner.Parent = instance
  7. end
  8.  
  9. function UILibrary.CreateGUI()
  10. local CoreGui = game:GetService("CoreGui")
  11.  
  12. local existingGui = CoreGui:FindFirstChild("fff")
  13. if existingGui then
  14. existingGui:Destroy()
  15. end
  16.  
  17. local screenGui = Instance.new("ScreenGui")
  18. screenGui.Name = "fff"
  19. screenGui.Parent = CoreGui
  20.  
  21. local MainFrame = Instance.new("Frame")
  22. MainFrame.Size = UDim2.new(0, 400, 0, 300)
  23. MainFrame.Position = UDim2.new(0.5, -200, 0.5, -150)
  24. MainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  25. MainFrame.BackgroundTransparency = 0.6
  26. MainFrame.Active = true
  27. MainFrame.Visible = false
  28. MainFrame.Parent = screenGui
  29. addCorner(MainFrame, 10)
  30.  
  31. local topFrame = Instance.new("Frame")
  32. topFrame.Size = UDim2.new(1, 0, 0, 40)
  33. topFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  34. topFrame.Parent = MainFrame
  35. addCorner(topFrame, 10)
  36.  
  37. local title = Instance.new("TextLabel")
  38. title.Size = UDim2.new(0, 200, 0, 40)
  39. title.Position = UDim2.new(0, 1, 0, 0)
  40. title.Text = "Title Here"
  41. title.TextColor3 = Color3.fromRGB(255, 255, 255)
  42. title.Font = Enum.Font.Gotham
  43. title.TextSize = 14
  44. title.BackgroundTransparency = 1
  45. title.Parent = topFrame
  46.  
  47. local description = Instance.new("TextLabel")
  48. description.Size = UDim2.new(0, 150, 0, 40)
  49. description.Position = UDim2.new(0, 140, 0, 0)
  50. description.Text = "Description Here"
  51. description.TextColor3 = Color3.fromRGB(169, 169, 169)
  52. description.Font = Enum.Font.Gotham
  53. description.TextSize = 12
  54. description.BackgroundTransparency = 1
  55. description.Parent = topFrame
  56.  
  57. local closeButton = Instance.new("TextButton")
  58. closeButton.Size = UDim2.new(0, 40, 0, 40)
  59. closeButton.Position = UDim2.new(1, -50, 0, 0)
  60. closeButton.Text = "X"
  61. closeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  62. closeButton.Font = Enum.Font.Gotham
  63. closeButton.TextSize = 20
  64. closeButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  65. closeButton.BackgroundTransparency = 0.6
  66. closeButton.Parent = topFrame
  67. addCorner(closeButton, 10)
  68.  
  69. local minimizeButton = Instance.new("TextButton")
  70. minimizeButton.Size = UDim2.new(0, 40, 0, 40)
  71. minimizeButton.Position = UDim2.new(1, -100, 0, 0)
  72. minimizeButton.Text = "_"
  73. minimizeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  74. minimizeButton.Font = Enum.Font.Gotham
  75. minimizeButton.TextSize = 20
  76. minimizeButton.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
  77. minimizeButton.BackgroundTransparency = 0.6
  78. minimizeButton.Parent = topFrame
  79. addCorner(minimizeButton, 10)
  80.  
  81. local toggleButton = Instance.new("TextButton")
  82. toggleButton.Size = UDim2.new(0, 50, 0, 50)
  83. toggleButton.Position = UDim2.new(0, 10, 0, 10)
  84. toggleButton.Text = "Show Menu"
  85. toggleButton.Font = Enum.Font.Gotham
  86. toggleButton.TextSize = 12
  87. toggleButton.Active = true
  88. toggleButton.Draggable = true
  89. toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  90. toggleButton.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  91. toggleButton.BackgroundTransparency = 0.6
  92. toggleButton.Parent = screenGui
  93. addCorner(toggleButton, 10)
  94.  
  95. toggleButton.MouseButton1Click:Connect(function()
  96. MainFrame.Visible = not MainFrame.Visible
  97. toggleButton.Text = MainFrame.Visible and "Hide Menu" or "Show Menu"
  98. end)
  99.  
  100. closeButton.MouseButton1Click:Connect(function()
  101. MainFrame:Destroy()
  102. toggleButton:Destroy()
  103. end)
  104.  
  105. local isMinimized = false
  106.  
  107. minimizeButton.MouseButton1Click:Connect(function()
  108. if isMinimized then
  109. MainFrame.Size = UDim2.new(0, 400, 0, 300)
  110. scrollFrame = true
  111. isMinimized = false
  112. else
  113. MainFrame.Size = UDim2.new(0, 400, 0, 40)
  114. scrollFrame = false
  115. isMinimized = true
  116. end
  117. end)
  118.  
  119. function UILibrary.UpdateTitleAndDescription(newTitle, newDescription)
  120. title.Text = newTitle
  121. description.Text = newDescription
  122. end
  123.  
  124. local ExtraFrame = Instance.new("Frame")
  125. ExtraFrame.Size = UDim2.new(0, 200, 0, 300)
  126. ExtraFrame.Position = UDim2.new(0, -210, 0, 0)
  127. ExtraFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
  128. ExtraFrame.BackgroundTransparency = 0.6
  129. ExtraFrame.Visible = false
  130. ExtraFrame.Parent = MainFrame
  131. addCorner(ExtraFrame, 10)
  132.  
  133. local scrollFrame = Instance.new("ScrollingFrame")
  134. scrollFrame.Size = UDim2.new(1, 0, 1, -10)
  135. scrollFrame.Position = UDim2.new(0, 0, 0, 5)
  136. scrollFrame.ScrollBarThickness = 10
  137. scrollFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  138. scrollFrame.BackgroundTransparency = 0.6
  139. scrollFrame.Parent = ExtraFrame
  140.  
  141. local UIListLayout = Instance.new("UIListLayout")
  142. UIListLayout.Padding = UDim.new(0, 10)
  143. UIListLayout.Parent = scrollFrame
  144.  
  145. UIListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  146. scrollFrame.CanvasSize = UDim2.new(0, 0, 0, UIListLayout.AbsoluteContentSize.Y)
  147. end)
  148.  
  149. local toggleExtraButton = Instance.new("TextButton")
  150. toggleExtraButton.Size = UDim2.new(0, 40, 0, 40)
  151. toggleExtraButton.Position = UDim2.new(0, -45, 0.5, -20)
  152. toggleExtraButton.Text = ">"
  153. toggleExtraButton.Font = Enum.Font.Gotham
  154. toggleExtraButton.TextSize = 20
  155. toggleExtraButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  156. toggleExtraButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  157. toggleExtraButton.Parent = MainFrame
  158. addCorner(toggleExtraButton, 10)
  159.  
  160. toggleExtraButton.MouseButton1Click:Connect(function()
  161. ExtraFrame.Visible = not ExtraFrame.Visible
  162. toggleExtraButton.Text = ExtraFrame.Visible and "<" or ">"
  163. end)
  164.  
  165. local scrollFrame = Instance.new("ScrollingFrame")
  166. scrollFrame.Size = UDim2.new(1, 0, 1, -50)
  167. scrollFrame.Position = UDim2.new(0, 0, 0, 40)
  168. scrollFrame.ScrollBarThickness = 10
  169. scrollFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  170. scrollFrame.BackgroundTransparency = 0.6
  171. scrollFrame.Parent = MainFrame
  172.  
  173. local UIListLayout = Instance.new("UIListLayout")
  174. UIListLayout.Padding = UDim.new(0, 10)
  175. UIListLayout.FillDirection = Enum.FillDirection.Vertical
  176. UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
  177. UIListLayout.Parent = scrollFrame
  178.  
  179. UIListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  180. scrollFrame.CanvasSize = UDim2.new(0, 0, 0, UIListLayout.AbsoluteContentSize.Y)
  181. end)
  182.  
  183. return {
  184. ScreenGui = screenGui,
  185. MainFrame = MainFrame,
  186. ExtraFrame = ExtraFrame,
  187. ScrollFrame = scrollFrame,
  188. }
  189. end
  190.  
  191. function UILibrary.CreateSection(scrollParent, titleText)
  192. local sectionFrame = Instance.new("Frame")
  193. sectionFrame.Size = UDim2.new(0.9, 0, 0, 40)
  194. sectionFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
  195. sectionFrame.BackgroundTransparency = 0.5
  196. sectionFrame.Parent = scrollParent
  197. addCorner(sectionFrame, 8)
  198.  
  199. local titleLabel = Instance.new("TextLabel")
  200. titleLabel.Size = UDim2.new(1, -20, 0, 20)
  201. titleLabel.Position = UDim2.new(0, 10, 0, 5)
  202. titleLabel.Font = Enum.Font.Gotham
  203. titleLabel.Text = titleText
  204. titleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  205. titleLabel.TextSize = 14
  206. titleLabel.TextXAlignment = Enum.TextXAlignment.Left
  207. titleLabel.BackgroundTransparency = 1
  208. titleLabel.Parent = sectionFrame
  209.  
  210. local contentFrame = Instance.new("Frame")
  211. contentFrame.Size = UDim2.new(1, -10, 0, 0)
  212. contentFrame.Position = UDim2.new(0, 5, 0, 25)
  213. contentFrame.BackgroundTransparency = 1
  214. contentFrame.Parent = sectionFrame
  215.  
  216. local layout = Instance.new("UIListLayout")
  217. layout.Padding = UDim.new(0, 5)
  218. layout.FillDirection = Enum.FillDirection.Vertical
  219. layout.Parent = contentFrame
  220.  
  221. layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  222. contentFrame.Size = UDim2.new(1, -10, 0, layout.AbsoluteContentSize.Y)
  223. sectionFrame.Size = UDim2.new(0.9, 0, 0, layout.AbsoluteContentSize.Y + 30)
  224. end)
  225.  
  226. return {
  227. Frame = contentFrame,
  228. AddElement = function(self, element)
  229. element.Parent = contentFrame
  230. end
  231. }
  232. end
  233.  
  234. function UILibrary.CreateLabel(parent, text)
  235. local label = Instance.new("TextLabel")
  236. label.Size = UDim2.new(0, 200, 0, 40)
  237. label.Text = text
  238. label.Font = Enum.Font.Gotham
  239. label.TextSize = 14
  240. label.TextColor3 = Color3.fromRGB(255, 255, 255)
  241. label.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  242. label.BackgroundTransparency = 1
  243. label.Parent = parent
  244. addCorner(label, 10)
  245.  
  246. return label
  247. end
  248.  
  249. function UILibrary.CreateDropdown(parent, options, defaultOption, callback)
  250. local dropdownFrame = Instance.new("Frame")
  251. dropdownFrame.Size = UDim2.new(0, 200, 0, 30)
  252. dropdownFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  253. dropdownFrame.BackgroundTransparency = 0.6
  254. dropdownFrame.Parent = parent
  255. addCorner(dropdownFrame, 10)
  256.  
  257. local dropdownButton = Instance.new("TextButton")
  258. dropdownButton.Size = UDim2.new(1, 0, 1, 0)
  259. dropdownButton.Text = "Select: " .. defaultOption
  260. dropdownButton.Font = Enum.Font.Gotham
  261. dropdownButton.TextSize = 14
  262. dropdownButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  263. dropdownButton.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  264. dropdownButton.BackgroundTransparency = 0.6
  265. dropdownButton.Parent = dropdownFrame
  266. addCorner(dropdownButton, 10)
  267.  
  268. local dropdownMenu = Instance.new("Frame")
  269. dropdownMenu.Size = UDim2.new(1, 0, 0, 150)
  270. dropdownMenu.Position = UDim2.new(0, 0, 1, 0)
  271. dropdownMenu.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  272. dropdownMenu.BackgroundTransparency = 0.5
  273. dropdownMenu.Visible = false
  274. dropdownMenu.ZIndex = 10
  275. dropdownMenu.Parent = dropdownFrame
  276. addCorner(dropdownMenu, 10)
  277.  
  278. local UIListLayoutDropdown = Instance.new("UIListLayout")
  279. UIListLayoutDropdown.Padding = UDim.new(0, 5)
  280. UIListLayoutDropdown.FillDirection = Enum.FillDirection.Vertical
  281. UIListLayoutDropdown.Parent = dropdownMenu
  282.  
  283. for _, option in ipairs(options) do
  284. local optionButton = Instance.new("TextButton")
  285. optionButton.Size = UDim2.new(1, 0, 0, 25)
  286. optionButton.Text = option
  287. optionButton.Font = Enum.Font.Gotham
  288. optionButton.TextSize = 14
  289. optionButton.ZIndex = 11
  290. optionButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  291. optionButton.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  292. optionButton.BackgroundTransparency = 0.6
  293. optionButton.Parent = dropdownMenu
  294. addCorner(optionButton, 5)
  295.  
  296. optionButton.MouseButton1Click:Connect(function()
  297. dropdownButton.Text = "Select: " .. option
  298. dropdownMenu.Visible = false
  299. callback(option)
  300. end)
  301. end
  302.  
  303. dropdownButton.MouseButton1Click:Connect(function()
  304. dropdownMenu.Visible = not dropdownMenu.Visible
  305. end)
  306. end
  307.  
  308. function UILibrary.CreateTextbox(parent, name, default, callback)
  309. local textboxFrame = Instance.new("Frame")
  310. textboxFrame.Size = UDim2.new(0, 260, 0, 40) -- Aumenté el ancho del frame
  311. textboxFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  312. textboxFrame.BackgroundTransparency = 0.4
  313. textboxFrame.Parent = parent
  314. addCorner(textboxFrame, 10)
  315.  
  316. local textboxLabel = Instance.new("TextLabel")
  317. textboxLabel.Size = UDim2.new(0, 140, 1, 0) -- Aumenté el ancho del label
  318. textboxLabel.Text = name .. ":"
  319. textboxLabel.Font = Enum.Font.Gotham
  320. textboxLabel.TextSize = 13
  321. textboxLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  322. textboxLabel.BackgroundTransparency = 1
  323. textboxLabel.Parent = textboxFrame
  324.  
  325. local textbox = Instance.new("TextBox")
  326. textbox.Size = UDim2.new(0, 100, 1, -10)
  327. textbox.Position = UDim2.new(0, 150, 0, 5) -- Ajusté la posición del textbox
  328. textbox.Text = tostring(default)
  329. textbox.Font = Enum.Font.Gotham
  330. textbox.TextSize = 14
  331. textbox.TextColor3 = Color3.fromRGB(255, 255, 255)
  332. textbox.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  333. textbox.BackgroundTransparency = 0.4
  334. textbox.Parent = textboxFrame
  335. addCorner(textbox, 10)
  336.  
  337. textbox.FocusLost:Connect(function()
  338. local value = tonumber(textbox.Text)
  339. if value then
  340. callback(value)
  341. else
  342. textbox.Text = tostring(default)
  343. end
  344. end)
  345. end
  346.  
  347. function UILibrary.CreateToggleButton(parent, name, defaultState, callback)
  348. local toggleButton = Instance.new("TextButton")
  349. toggleButton.Size = UDim2.new(0, 200, 0, 30)
  350. toggleButton.Text = name .. ": " .. (defaultState and "ON" or "OFF")
  351. toggleButton.Font = Enum.Font.Gotham
  352. toggleButton.TextSize = 14
  353. toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  354. toggleButton.BackgroundColor3 = defaultState and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
  355. toggleButton.BackgroundTransparency = 0.6
  356. toggleButton.Parent = parent
  357. addCorner(toggleButton, 5)
  358.  
  359. toggleButton.MouseButton1Click:Connect(function()
  360. local state = not (toggleButton.Text:find("ON") and true or false)
  361. toggleButton.Text = name .. ": " .. (state and "ON" or "OFF")
  362. toggleButton.BackgroundColor3 = state and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
  363. callback(state)
  364. end)
  365. end
  366.  
  367. function UILibrary.CreateColorPicker(parent, name, defaultColor, callback)
  368. local colorPickerFrame = Instance.new("Frame")
  369. colorPickerFrame.Size = UDim2.new(0, 260, 0, 40) -- Aumenté el ancho del frame
  370. colorPickerFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  371. colorPickerFrame.BackgroundTransparency = 0.4
  372. colorPickerFrame.Parent = parent
  373. addCorner(colorPickerFrame, 10)
  374.  
  375. local colorPickerLabel = Instance.new("TextLabel")
  376. colorPickerLabel.Size = UDim2.new(0, 140, 1, 0) -- Aumenté el ancho del label
  377. colorPickerLabel.Text = name .. ":"
  378. colorPickerLabel.Font = Enum.Font.Gotham
  379. colorPickerLabel.TextSize = 15
  380. colorPickerLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  381. colorPickerLabel.BackgroundTransparency = 1
  382. colorPickerLabel.Parent = colorPickerFrame
  383.  
  384. local colorPreview = Instance.new("Frame")
  385. colorPreview.Size = UDim2.new(0, 50, 0, 20)
  386. colorPreview.Position = UDim2.new(0, 150, 0.5, -10) -- Ajusté la posición
  387. colorPreview.BackgroundColor3 = defaultColor
  388. colorPreview.Parent = colorPickerFrame
  389. addCorner(colorPreview, 5)
  390.  
  391. local colorPickerButton = Instance.new("TextButton")
  392. colorPickerButton.Size = UDim2.new(0, 30, 0, 20)
  393. colorPickerButton.Position = UDim2.new(0, 210, 0.5, -10) -- Ajusté la posición
  394. colorPickerButton.Text = "..."
  395. colorPickerButton.Font = Enum.Font.Gotham
  396. colorPickerButton.TextSize = 14
  397. colorPickerButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  398. colorPickerButton.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  399. colorPickerButton.BackgroundTransparency = 0.6
  400. colorPickerButton.Parent = colorPickerFrame
  401. addCorner(colorPickerButton, 5)
  402.  
  403. local colorPickerGui = Instance.new("ScreenGui")
  404. colorPickerGui.Name = "ColorPickerGui"
  405. colorPickerGui.Parent = parent.Parent
  406.  
  407. local colorPickerPopup = Instance.new("Frame")
  408. colorPickerPopup.Size = UDim2.new(0, 200, 0, 200)
  409. colorPickerPopup.Position = UDim2.new(0.5, -100, 0.5, -100)
  410. colorPickerPopup.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  411. colorPickerPopup.BackgroundTransparency = 0.6
  412. colorPickerPopup.Visible = false
  413. colorPickerPopup.Parent = colorPickerGui
  414. addCorner(colorPickerPopup, 10)
  415.  
  416. local colorWheel = Instance.new("ImageLabel")
  417. colorWheel.Size = UDim2.new(0, 150, 0, 150)
  418. colorWheel.Position = UDim2.new(0.5, -75, 0.5, -75)
  419. colorWheel.Image = "rbxassetid://142488478"
  420. colorWheel.BackgroundTransparency = 1
  421. colorWheel.Active = true
  422. colorWheel.Parent = colorPickerPopup
  423.  
  424. local colorSelector = Instance.new("Frame")
  425. colorSelector.Size = UDim2.new(0, 10, 0, 10)
  426. colorSelector.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  427. colorSelector.BorderSizePixel = 2
  428. colorSelector.Parent = colorWheel
  429. colorSelector.Active = true
  430. addCorner(colorSelector, 5)
  431.  
  432. local confirmButton = Instance.new("TextButton")
  433. confirmButton.Size = UDim2.new(0, 80, 0, 30)
  434. confirmButton.Position = UDim2.new(0.5, -40, 1, -40)
  435. confirmButton.Text = "Confirm"
  436. confirmButton.Font = Enum.Font.Gotham
  437. confirmButton.TextSize = 14
  438. confirmButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  439. confirmButton.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  440. confirmButton.BackgroundTransparency = 0.6
  441. confirmButton.Parent = colorPickerPopup
  442. addCorner(confirmButton, 5)
  443.  
  444. colorPickerButton.MouseButton1Click:Connect(function()
  445. colorPickerPopup.Visible = true
  446. end)
  447.  
  448. local function updateColor(input)
  449. local mousePosition = input.Position
  450. local relativePosition = colorWheel.AbsolutePosition
  451. local x = (mousePosition.X - relativePosition.X) / colorWheel.AbsoluteSize.X
  452. local y = (mousePosition.Y - relativePosition.Y) / colorWheel.AbsoluteSize.Y
  453. x = math.clamp(x, 0, 1)
  454. y = math.clamp(y, 0, 1)
  455.  
  456. colorSelector.Position = UDim2.new(x, -5, y, -5)
  457.  
  458. local color = Color3.fromHSV(x, 1 - y, 1)
  459. colorPreview.BackgroundColor3 = color
  460. end
  461.  
  462. colorWheel.InputBegan:Connect(function(input)
  463. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  464. updateColor(input)
  465. local connection
  466. connection = input.Changed:Connect(function()
  467. if input.UserInputState == Enum.UserInputState.End then
  468. connection:Disconnect()
  469. else
  470. updateColor(input)
  471. end
  472. end)
  473. end
  474. end)
  475.  
  476. confirmButton.MouseButton1Click:Connect(function()
  477. colorPickerPopup.Visible = false
  478. callback(colorPreview.BackgroundColor3)
  479. end)
  480. end
  481.  
  482. function UILibrary.CreateSlider(parent, name, minValue, maxValue, defaultValue, increment, callback)
  483. local sliderFrame = Instance.new("Frame")
  484. sliderFrame.Size = UDim2.new(0, 200, 0, 50)
  485. sliderFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  486. sliderFrame.BackgroundTransparency = 0.6
  487. sliderFrame.Parent = parent
  488. addCorner(sliderFrame, 10)
  489.  
  490. local sliderLabel = Instance.new("TextLabel")
  491. sliderLabel.Size = UDim2.new(0, 100, 0, 20)
  492. sliderLabel.Position = UDim2.new(0, 10, 0, 5)
  493. sliderLabel.Text = name .. ": " .. defaultValue
  494. sliderLabel.Font = Enum.Font.Gotham
  495. sliderLabel.TextSize = 14
  496. sliderLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  497. sliderLabel.BackgroundTransparency = 1
  498. sliderLabel.Parent = sliderFrame
  499.  
  500. local sliderTrack = Instance.new("Frame")
  501. sliderTrack.Size = UDim2.new(0, 180, 0, 5)
  502. sliderTrack.Position = UDim2.new(0, 10, 0, 30)
  503. sliderTrack.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
  504. sliderTrack.Parent = sliderFrame
  505. addCorner(sliderTrack, 5)
  506.  
  507. local sliderThumb = Instance.new("Frame")
  508. sliderThumb.Size = UDim2.new(0, 10, 0, 15)
  509. sliderThumb.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
  510. sliderThumb.Parent = sliderTrack
  511. addCorner(sliderThumb, 5)
  512.  
  513. local function round(value, decimalPlaces)
  514. local factor = 10 ^ decimalPlaces
  515. return math.floor(value * factor + 0.5) / factor
  516. end
  517.  
  518. local function updateSlider(input)
  519. local mousePosition = input.Position
  520. local relativePosition = sliderTrack.AbsolutePosition
  521. local x = (mousePosition.X - relativePosition.X) / sliderTrack.AbsoluteSize.X
  522. x = math.clamp(x, 0, 1)
  523.  
  524. local rawValue = minValue + (maxValue - minValue) * x
  525. local value = round(rawValue - (rawValue % increment), 2) -- Redondear al incremento más cercano
  526.  
  527. value = math.clamp(value, minValue, maxValue)
  528.  
  529. local thumbPosition = (value - minValue) / (maxValue - minValue)
  530. sliderThumb.Position = UDim2.new(thumbPosition, -5, 0.5, -7.5)
  531. sliderLabel.Text = name .. ": " .. value
  532. callback(value)
  533. end
  534.  
  535. sliderTrack.InputBegan:Connect(function(input)
  536. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  537. updateSlider(input)
  538. local connection
  539. connection = input.Changed:Connect(function()
  540. if input.UserInputState == Enum.UserInputState.End then
  541. connection:Disconnect()
  542. else
  543. updateSlider(input)
  544. end
  545. end)
  546. end
  547. end)
  548.  
  549. local initialValue = round(defaultValue - (defaultValue % increment), 2)
  550. local initialX = (initialValue - minValue) / (maxValue - minValue)
  551. sliderThumb.Position = UDim2.new(initialX, -5, 0.5, -7.5)
  552. sliderLabel.Text = name .. ": " .. initialValue
  553. end
  554.  
  555. return UILibrary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement