tomoneko

Untitled

Apr 21st, 2025 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.41 KB | None | 0 0
  1. local Library = {}
  2.  
  3. local TweenService = game:GetService("TweenService")
  4. local UserInputService = game:GetService("UserInputService")
  5. local GuiService = game:GetService("GuiService")
  6.  
  7. local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  8.  
  9. local Theme = {
  10. Background = Color3.fromRGB(0, 0, 0),
  11. BackgroundTransparency = 0.4,
  12. Accent = Color3.fromRGB(60, 120, 220),
  13. AccentHover = Color3.fromRGB(80, 140, 255),
  14. Section = Color3.fromRGB(20, 20, 30),
  15. SectionTransparency = 0.2,
  16. Text = Color3.fromRGB(230, 230, 230),
  17. SubText = Color3.fromRGB(180, 180, 255),
  18. Border = Color3.fromRGB(60, 60, 80),
  19. Toggle = {
  20. Background = Color3.fromRGB(50, 50, 70),
  21. Enabled = Color3.fromRGB(60, 220, 120),
  22. Disabled = Color3.fromRGB(150, 150, 170)
  23. },
  24. Slider = {
  25. Background = Color3.fromRGB(40, 40, 60),
  26. Fill = Color3.fromRGB(70, 140, 240)
  27. }
  28. }
  29.  
  30. local coreGui = nil
  31. local function ensureCoreGui()
  32. if not coreGui then
  33. coreGui = Instance.new("ScreenGui")
  34. coreGui.Name = "SparrowUILibraryCoreGui"
  35. coreGui.ResetOnSpawn = false
  36. coreGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  37. coreGui.DisplayOrder = 999
  38.  
  39. if game:GetService("RunService"):IsStudio() then
  40. coreGui.Parent = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
  41. else
  42. coreGui.Parent = game:GetService("CoreGui")
  43. end
  44. end
  45. end
  46.  
  47. local function isMobile()
  48. return UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled
  49. end
  50.  
  51. local function makeElementDraggable(element, handle)
  52. local dragging = false
  53. local dragInput, dragStart, startPos
  54.  
  55. local function updateDrag(input)
  56. if dragging then
  57. local delta = input.Position - dragStart
  58. element.Position = UDim2.new(
  59. startPos.X.Scale,
  60. startPos.X.Offset + delta.X,
  61. startPos.Y.Scale,
  62. startPos.Y.Offset + delta.Y
  63. )
  64. end
  65. end
  66.  
  67. handle.InputBegan:Connect(function(input)
  68. if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) then
  69. dragging = true
  70. dragStart = input.Position
  71. startPos = element.Position
  72.  
  73. input.Changed:Connect(function()
  74. if input.UserInputState == Enum.UserInputState.End then
  75. dragging = false
  76. end
  77. end)
  78. end
  79. end)
  80.  
  81. handle.InputChanged:Connect(function(input)
  82. if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  83. dragInput = input
  84. end
  85. end)
  86.  
  87. UserInputService.InputChanged:Connect(function(input)
  88. if input == dragInput and dragging then
  89. updateDrag(input)
  90. end
  91. end)
  92. end
  93.  
  94. function Library:CreateWindow(config)
  95. ensureCoreGui()
  96.  
  97. config = config or {}
  98. local title = config.Title or "Sparrow UI"
  99.  
  100. local isMobileDevice = isMobile()
  101. local safeAreaInsets = GuiService:GetGuiInset()
  102.  
  103. local defaultSize
  104. if isMobileDevice then
  105. defaultSize = UDim2.new(0, 280, 0, 320)
  106. else
  107. defaultSize = UDim2.new(0, 400, 0, 320)
  108. end
  109.  
  110. local size = config.Size or defaultSize
  111. local originalSize = size
  112. local isMinimized = false
  113.  
  114. local frame = Instance.new("Frame")
  115. frame.Size = size
  116.  
  117. if isMobileDevice then
  118. frame.Position = UDim2.new(0, 10, 0, safeAreaInsets.Y + 10)
  119. else
  120. frame.Position = UDim2.new(0.5, -size.X.Offset/2, 0.5, -size.Y.Offset/2)
  121. end
  122.  
  123. frame.BackgroundColor3 = Theme.Background
  124. frame.BackgroundTransparency = Theme.BackgroundTransparency
  125. frame.BorderSizePixel = 0
  126. frame.ClipsDescendants = true
  127. frame.Active = true
  128. frame.Parent = coreGui
  129.  
  130. local corner = Instance.new("UICorner", frame)
  131. corner.CornerRadius = UDim.new(0, 12)
  132.  
  133. local dropShadow = Instance.new("ImageLabel")
  134. dropShadow.Size = UDim2.new(1, 30, 1, 30)
  135. dropShadow.Position = UDim2.new(0.5, 0, 0.5, 0)
  136. dropShadow.AnchorPoint = Vector2.new(0.5, 0.5)
  137. dropShadow.Image = "rbxassetid://6014261993"
  138. dropShadow.BackgroundTransparency = 1
  139. dropShadow.ImageTransparency = 0.5
  140. dropShadow.ZIndex = 0
  141. dropShadow.ScaleType = Enum.ScaleType.Slice
  142. dropShadow.SliceCenter = Rect.new(49, 49, 450, 450)
  143. dropShadow.Parent = frame
  144.  
  145. local titleBar = Instance.new("Frame")
  146. titleBar.Size = UDim2.new(1, 0, 0, 36)
  147. titleBar.BackgroundColor3 = Theme.Background:Lerp(Color3.new(0, 0, 0), 0.2)
  148. titleBar.BackgroundTransparency = Theme.BackgroundTransparency - 0.1
  149. titleBar.BorderSizePixel = 0
  150. titleBar.Parent = frame
  151.  
  152. local titleBarCorner = Instance.new("UICorner", titleBar)
  153. titleBarCorner.CornerRadius = UDim.new(0, 10)
  154.  
  155. local titleLabel = Instance.new("TextLabel")
  156. titleLabel.Size = UDim2.new(1, -100, 1, 0)
  157. titleLabel.Position = UDim2.new(0, 15, 0, 0)
  158. titleLabel.BackgroundTransparency = 1
  159. titleLabel.Text = title
  160. titleLabel.Font = Enum.Font.GothamBold
  161. titleLabel.TextSize = 18
  162. titleLabel.TextColor3 = Theme.Text
  163. titleLabel.TextXAlignment = Enum.TextXAlignment.Left
  164. titleLabel.Parent = titleBar
  165.  
  166. local minimizeBtn = Instance.new("TextButton")
  167. minimizeBtn.Size = UDim2.new(0, 26, 0, 26)
  168. minimizeBtn.Position = UDim2.new(1, -60, 0, 5)
  169. minimizeBtn.BackgroundColor3 = Color3.fromRGB(60, 180, 120)
  170. minimizeBtn.Text = "-"
  171. minimizeBtn.Font = Enum.Font.GothamBold
  172. minimizeBtn.TextSize = 18
  173. minimizeBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
  174. minimizeBtn.Parent = titleBar
  175.  
  176. local minimizeBtnCorner = Instance.new("UICorner", minimizeBtn)
  177. minimizeBtnCorner.CornerRadius = UDim.new(0, 5)
  178.  
  179. local closeBtn = Instance.new("TextButton")
  180. closeBtn.Size = UDim2.new(0, 26, 0, 26)
  181. closeBtn.Position = UDim2.new(1, -30, 0, 5)
  182. closeBtn.BackgroundColor3 = Color3.fromRGB(220, 60, 60)
  183. closeBtn.Text = "x"
  184. closeBtn.Font = Enum.Font.GothamBold
  185. closeBtn.TextSize = 16
  186. closeBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
  187. closeBtn.Parent = titleBar
  188.  
  189. local closeBtnCorner = Instance.new("UICorner", closeBtn)
  190. closeBtnCorner.CornerRadius = UDim.new(0, 5)
  191.  
  192. local contentContainer = Instance.new("Frame")
  193. contentContainer.Size = UDim2.new(1, 0, 1, -36)
  194. contentContainer.Position = UDim2.new(0, 0, 0, 36)
  195. contentContainer.BackgroundTransparency = 1
  196. contentContainer.Parent = frame
  197.  
  198. minimizeBtn.MouseButton1Click:Connect(function()
  199. isMinimized = not isMinimized
  200.  
  201. if isMinimized then
  202. contentContainer.Visible = false
  203. TweenService:Create(frame, tweenInfo, {
  204. Size = UDim2.new(0, originalSize.X.Offset, 0, 36)
  205. }):Play()
  206. minimizeBtn.Text = "+"
  207. else
  208. contentContainer.Visible = true
  209. TweenService:Create(frame, tweenInfo, {
  210. Size = originalSize
  211. }):Play()
  212. minimizeBtn.Text = "-"
  213. end
  214. end)
  215.  
  216. closeBtn.MouseButton1Click:Connect(function()
  217. frame.Visible = false
  218. dropShadow.Visible = false
  219. end)
  220.  
  221. makeElementDraggable(frame, titleBar)
  222.  
  223. local tabsContainer = Instance.new("ScrollingFrame")
  224. tabsContainer.Size = UDim2.new(1, -10, 0, 36)
  225. tabsContainer.Position = UDim2.new(0, 5, 0, 4)
  226. tabsContainer.BackgroundTransparency = 1
  227. tabsContainer.ScrollBarThickness = 2
  228. tabsContainer.ScrollingDirection = Enum.ScrollingDirection.X
  229. tabsContainer.ScrollBarImageColor3 = Theme.Accent
  230. tabsContainer.Parent = contentContainer
  231.  
  232. local tabsLayout = Instance.new("UIListLayout")
  233. tabsLayout.FillDirection = Enum.FillDirection.Horizontal
  234. tabsLayout.Padding = UDim.new(0, 4)
  235. tabsLayout.Parent = tabsContainer
  236.  
  237. local contentArea = Instance.new("Frame")
  238. contentArea.Size = UDim2.new(1, -16, 1, -50)
  239. contentArea.Position = UDim2.new(0, 8, 0, 44)
  240. contentArea.BackgroundTransparency = 1
  241. contentArea.ClipsDescendants = true
  242. contentArea.Parent = contentContainer
  243.  
  244. local tabFolder = Instance.new("Folder")
  245. tabFolder.Name = "Tabs"
  246. tabFolder.Parent = contentArea
  247.  
  248. local tabs = {}
  249. local selectedTab = nil
  250. local tabCount = 0
  251.  
  252. function Library:CreateTab(tabName)
  253. tabCount = tabCount + 1
  254.  
  255. local buttonWidth = isMobileDevice and 80 or 100
  256.  
  257. local tabBtn = Instance.new("TextButton")
  258. tabBtn.Size = UDim2.new(0, buttonWidth, 0, 30)
  259. tabBtn.BackgroundColor3 = Theme.Section
  260. tabBtn.BackgroundTransparency = Theme.SectionTransparency
  261. tabBtn.Text = tabName
  262. tabBtn.Font = Enum.Font.Gotham
  263. tabBtn.TextSize = isMobileDevice and 12 or 14
  264. tabBtn.TextColor3 = Theme.Text
  265. tabBtn.Parent = tabsContainer
  266.  
  267. local tabBtnCorner = Instance.new("UICorner", tabBtn)
  268. tabBtnCorner.CornerRadius = UDim.new(0, 6)
  269.  
  270. local tabFrame = Instance.new("ScrollingFrame")
  271. tabFrame.Size = UDim2.new(1, 0, 1, 0)
  272. tabFrame.BackgroundTransparency = 1
  273. tabFrame.BorderSizePixel = 0
  274. tabFrame.ScrollBarThickness = 4
  275. tabFrame.Visible = false
  276. tabFrame.Parent = tabFolder
  277. tabFrame.ScrollBarImageColor3 = Theme.Accent
  278. tabFrame.AutomaticCanvasSize = Enum.AutomaticSize.Y
  279.  
  280. local itemsList = Instance.new("UIListLayout")
  281. itemsList.Padding = UDim.new(0, 8)
  282. itemsList.SortOrder = Enum.SortOrder.LayoutOrder
  283. itemsList.HorizontalAlignment = Enum.HorizontalAlignment.Center
  284. itemsList.Parent = tabFrame
  285.  
  286. table.insert(tabs, {Button = tabBtn, Frame = tabFrame})
  287.  
  288. tabBtn.MouseButton1Click:Connect(function()
  289. for _, tab in ipairs(tabs) do
  290. tab.Frame.Visible = false
  291. tab.Button.BackgroundColor3 = Theme.Section
  292. tab.Button.BackgroundTransparency = Theme.SectionTransparency
  293. end
  294. tabFrame.Visible = true
  295. tabBtn.BackgroundColor3 = Theme.Accent
  296. tabBtn.BackgroundTransparency = 0.1
  297. selectedTab = tabFrame
  298. end)
  299.  
  300. if tabCount == 1 then
  301. tabBtn.BackgroundColor3 = Theme.Accent
  302. tabBtn.BackgroundTransparency = 0.1
  303. tabFrame.Visible = true
  304. selectedTab = tabFrame
  305. end
  306.  
  307. tabsContainer.CanvasSize = UDim2.new(0, tabsLayout.AbsoluteContentSize.X, 0, 0)
  308.  
  309. local tabAPI = {}
  310.  
  311. function tabAPI:AddSection(title)
  312. local section = Instance.new("Frame")
  313. section.Size = UDim2.new(1, -10, 0, 0)
  314. section.BackgroundColor3 = Theme.Section
  315. section.BackgroundTransparency = Theme.SectionTransparency
  316. section.AutomaticSize = Enum.AutomaticSize.Y
  317. section.Parent = tabFrame
  318.  
  319. -- 下に余白をつける
  320. local padding = Instance.new("UIPadding")
  321. padding.PaddingBottom = UDim.new(0, 10)
  322. padding.Parent = section
  323.  
  324.  
  325. local sectionCorner = Instance.new("UICorner", section)
  326. sectionCorner.CornerRadius = UDim.new(0, 8)
  327.  
  328. local sectionTitle = Instance.new("TextLabel")
  329. sectionTitle.Size = UDim2.new(1, 0, 0, 24)
  330. sectionTitle.BackgroundTransparency = 1
  331. sectionTitle.Text = title
  332. sectionTitle.Font = Enum.Font.GothamBold
  333. sectionTitle.TextSize = isMobileDevice and 12 or 14
  334. sectionTitle.TextColor3 = Theme.SubText
  335. sectionTitle.Parent = section
  336.  
  337. local itemContainer = Instance.new("Frame")
  338. itemContainer.Size = UDim2.new(1, -20, 0, 0)
  339. itemContainer.Position = UDim2.new(0, 10, 0, 30)
  340. itemContainer.BackgroundTransparency = 1
  341. itemContainer.AutomaticSize = Enum.AutomaticSize.Y
  342. itemContainer.Parent = section
  343.  
  344. local itemsList = Instance.new("UIListLayout")
  345. itemsList.Padding = UDim.new(0, 6)
  346. itemsList.SortOrder = Enum.SortOrder.LayoutOrder
  347. itemsList.Parent = itemContainer
  348.  
  349. local sectionAPI = {}
  350.  
  351. function sectionAPI:AddLabel(text)
  352. local label = Instance.new("TextLabel")
  353. label.Size = UDim2.new(1, 0, 0, 20)
  354. label.BackgroundTransparency = 1
  355. label.Text = text
  356. label.Font = Enum.Font.Gotham
  357. label.TextSize = isMobileDevice and 12 or 14
  358. label.TextColor3 = Theme.Text
  359. label.TextXAlignment = Enum.TextXAlignment.Left
  360. label.Parent = itemContainer
  361.  
  362. local labelAPI = {}
  363. function labelAPI:UpdateText(newText)
  364. label.Text = newText
  365. end
  366.  
  367. return labelAPI
  368. end
  369.  
  370. function sectionAPI:AddButton(text, callback)
  371. local btn = Instance.new("TextButton")
  372. btn.Size = UDim2.new(1, 0, 0, isMobileDevice and 32 or 28)
  373. btn.BackgroundColor3 = Theme.Accent
  374. btn.BackgroundTransparency = 0.2
  375. btn.Text = text
  376. btn.Font = Enum.Font.Gotham
  377. btn.TextSize = isMobileDevice and 12 or 14
  378. btn.TextColor3 = Theme.Text
  379. btn.Parent = itemContainer
  380.  
  381. local btnCorner = Instance.new("UICorner", btn)
  382. btnCorner.CornerRadius = UDim.new(0, 6)
  383.  
  384. btn.MouseButton1Down:Connect(function()
  385. TweenService:Create(btn, tweenInfo, {BackgroundColor3 = Theme.AccentHover}):Play()
  386. end)
  387.  
  388. btn.MouseButton1Up:Connect(function()
  389. TweenService:Create(btn, tweenInfo, {BackgroundColor3 = Theme.Accent}):Play()
  390. end)
  391.  
  392. btn.MouseButton1Click:Connect(function()
  393. if callback then callback() end
  394. end)
  395.  
  396. local buttonAPI = {}
  397. function buttonAPI:UpdateText(newText)
  398. btn.Text = newText
  399. end
  400.  
  401. return buttonAPI
  402. end
  403.  
  404. function sectionAPI:AddToggle(text, default, callback)
  405. local toggleValue = default or false
  406.  
  407. local toggleContainer = Instance.new("Frame")
  408. toggleContainer.Size = UDim2.new(1, 0, 0, isMobileDevice and 34 or 30)
  409. toggleContainer.BackgroundTransparency = 1
  410. toggleContainer.Parent = itemContainer
  411.  
  412. local toggleLabel = Instance.new("TextLabel")
  413. toggleLabel.Size = UDim2.new(1, -54, 1, 0)
  414. toggleLabel.BackgroundTransparency = 1
  415. toggleLabel.Text = text
  416. toggleLabel.Font = Enum.Font.Gotham
  417. toggleLabel.TextSize = isMobileDevice and 12 or 14
  418. toggleLabel.TextColor3 = Theme.Text
  419. toggleLabel.TextXAlignment = Enum.TextXAlignment.Left
  420. toggleLabel.Parent = toggleContainer
  421.  
  422. local toggleBtn = Instance.new("Frame")
  423. toggleBtn.Size = UDim2.new(0, 44, 0, 22)
  424. toggleBtn.Position = UDim2.new(1, -44, 0.5, -11)
  425. toggleBtn.BackgroundColor3 = Theme.Toggle.Background
  426. toggleBtn.Parent = toggleContainer
  427.  
  428. local toggleBtnCorner = Instance.new("UICorner", toggleBtn)
  429. toggleBtnCorner.CornerRadius = UDim.new(1, 0)
  430.  
  431. local toggleCircle = Instance.new("Frame")
  432. toggleCircle.Size = UDim2.new(0, 16, 0, 16)
  433. toggleCircle.Position = UDim2.new(0, 3, 0.5, -8)
  434. toggleCircle.BackgroundColor3 = toggleValue and Theme.Toggle.Enabled or Theme.Toggle.Disabled
  435. toggleCircle.Parent = toggleBtn
  436.  
  437. local toggleCircleCorner = Instance.new("UICorner", toggleCircle)
  438. toggleCircleCorner.CornerRadius = UDim.new(1, 0)
  439.  
  440. local toggleClickArea = Instance.new("TextButton")
  441. toggleClickArea.Size = UDim2.new(1, 0, 1, 0)
  442. toggleClickArea.BackgroundTransparency = 1
  443. toggleClickArea.Text = ""
  444. toggleClickArea.Parent = toggleContainer
  445.  
  446. local function updateToggle()
  447. local targetPos = toggleValue and UDim2.new(1, -19, 0.5, -8) or UDim2.new(0, 3, 0.5, -8)
  448. local targetColor = toggleValue and Theme.Toggle.Enabled or Theme.Toggle.Disabled
  449.  
  450. TweenService:Create(toggleCircle, tweenInfo, {
  451. Position = targetPos,
  452. BackgroundColor3 = targetColor
  453. }):Play()
  454.  
  455. if callback then
  456. callback(toggleValue)
  457. end
  458. end
  459.  
  460. updateToggle()
  461.  
  462. toggleClickArea.MouseButton1Click:Connect(function()
  463. toggleValue = not toggleValue
  464. updateToggle()
  465. end)
  466.  
  467. local toggleAPI = {}
  468.  
  469. function toggleAPI:Set(value)
  470. if toggleValue ~= value then
  471. toggleValue = value
  472. updateToggle()
  473. end
  474. end
  475.  
  476. function toggleAPI:Get()
  477. return toggleValue
  478. end
  479.  
  480. return toggleAPI
  481. end
  482.  
  483. function sectionAPI:AddSlider(text, minVal, maxVal, defaultVal, precision, callback)
  484. local sliderValue = defaultVal or minVal
  485. precision = precision or 1
  486.  
  487. local sliderContainer = Instance.new("Frame")
  488. sliderContainer.Size = UDim2.new(1, 0, 0, isMobileDevice and 55 or 50)
  489. sliderContainer.BackgroundTransparency = 1
  490. sliderContainer.Parent = itemContainer
  491.  
  492. local sliderLabel = Instance.new("TextLabel")
  493. sliderLabel.Size = UDim2.new(1, 0, 0, 20)
  494. sliderLabel.BackgroundTransparency = 1
  495. sliderLabel.Text = text
  496. sliderLabel.Font = Enum.Font.Gotham
  497. sliderLabel.TextSize = isMobileDevice and 12 or 14
  498. sliderLabel.TextColor3 = Theme.Text
  499. sliderLabel.TextXAlignment = Enum.TextXAlignment.Left
  500. sliderLabel.Parent = sliderContainer
  501.  
  502. local valueLabel = Instance.new("TextLabel")
  503. valueLabel.Size = UDim2.new(0, 50, 0, 20)
  504. valueLabel.Position = UDim2.new(1, -50, 0, 0)
  505. valueLabel.BackgroundTransparency = 1
  506. valueLabel.Text = tostring(sliderValue)
  507. valueLabel.Font = Enum.Font.GothamBold
  508. valueLabel.TextSize = isMobileDevice and 12 or 14
  509. valueLabel.TextColor3 = Theme.Text
  510. valueLabel.Parent = sliderContainer
  511.  
  512. local sliderBg = Instance.new("Frame")
  513. sliderBg.Size = UDim2.new(1, 0, 0, isMobileDevice and 12 or 10)
  514. sliderBg.Position = UDim2.new(0, 0, 0, 30)
  515. sliderBg.BackgroundColor3 = Theme.Slider.Background
  516. sliderBg.BackgroundTransparency = 0.2
  517. sliderBg.Parent = sliderContainer
  518.  
  519. local sliderBgCorner = Instance.new("UICorner", sliderBg)
  520. sliderBgCorner.CornerRadius = UDim.new(0, 5)
  521.  
  522. local sliderFill = Instance.new("Frame")
  523. sliderFill.Size = UDim2.new((sliderValue - minVal) / (maxVal - minVal), 0, 1, 0)
  524. sliderFill.BackgroundColor3 = Theme.Slider.Fill
  525. sliderFill.Parent = sliderBg
  526.  
  527. local sliderFillCorner = Instance.new("UICorner", sliderFill)
  528. sliderFillCorner.CornerRadius = UDim.new(0, 5)
  529.  
  530. local sliderBtn = Instance.new("TextButton")
  531. sliderBtn.Size = UDim2.new(1, 0, 1, 0)
  532. sliderBtn.BackgroundTransparency = 1
  533. sliderBtn.Text = ""
  534. sliderBtn.Parent = sliderBg
  535.  
  536. local function updateSlider(value)
  537. value = math.clamp(value, minVal, maxVal)
  538. value = math.floor(value * 10^precision) / 10^precision
  539.  
  540. sliderValue = value
  541. valueLabel.Text = tostring(value)
  542.  
  543. local percent = (value - minVal) / (maxVal - minVal)
  544. TweenService:Create(sliderFill, TweenInfo.new(0.1), {
  545. Size = UDim2.new(percent, 0, 1, 0)
  546. }):Play()
  547.  
  548. if callback then
  549. callback(value)
  550. end
  551. end
  552.  
  553. updateSlider(sliderValue)
  554.  
  555. local dragging = false
  556.  
  557. sliderBtn.InputBegan:Connect(function(input)
  558. if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) then
  559. dragging = true
  560.  
  561. local inputPosition = input.Position.X
  562. local sliderPosition = sliderBg.AbsolutePosition.X
  563. local sliderSize = sliderBg.AbsoluteSize.X
  564.  
  565. local relativePos = math.clamp(inputPosition - sliderPosition, 0, sliderSize)
  566. local percent = relativePos / sliderSize
  567.  
  568. local value = minVal + (maxVal - minVal) * percent
  569. updateSlider(value)
  570. end
  571. end)
  572.  
  573. UserInputService.InputEnded:Connect(function(input)
  574. if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) then
  575. dragging = false
  576. end
  577. end)
  578.  
  579. UserInputService.InputChanged:Connect(function(input)
  580. if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
  581. local inputPosition = input.Position.X
  582. local sliderPosition = sliderBg.AbsolutePosition.X
  583. local sliderSize = sliderBg.AbsoluteSize.X
  584.  
  585. local relativePos = math.clamp(inputPosition - sliderPosition, 0, sliderSize)
  586. local percent = relativePos / sliderSize
  587.  
  588. local value = minVal + (maxVal - minVal) * percent
  589. updateSlider(value)
  590. end
  591. end)
  592.  
  593. local sliderAPI = {}
  594.  
  595. function sliderAPI:Set(value)
  596. updateSlider(value)
  597. end
  598.  
  599. function sliderAPI:Get()
  600. return sliderValue
  601. end
  602.  
  603. return sliderAPI
  604. end
  605.  
  606. return sectionAPI
  607. end
  608.  
  609. return tabAPI
  610. end
  611.  
  612. return Library
  613. end
  614.  
  615. return Library
Add Comment
Please, Sign In to add comment