Advertisement
NiceBBMBThai

TEST UI

Nov 21st, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.17 KB | None | 0 0
  1. local Library = {Toggle = true,FirstTab = nil,TabCount = 0,ColorTable = {}}
  2.  
  3. local RunService = game:GetService("RunService")
  4. local HttpService = game:GetService("HttpService")
  5. local TweenService = game:GetService("TweenService")
  6. local UserInputService = game:GetService("UserInputService")
  7.  
  8. local function MakeDraggable(ClickObject, Object)
  9. local Dragging = nil
  10. local DragInput = nil
  11. local DragStart = nil
  12. local StartPosition = nil
  13.  
  14. ClickObject.InputBegan:Connect(function(Input)
  15. if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
  16. Dragging = true
  17. DragStart = Input.Position
  18. StartPosition = Object.Position
  19.  
  20. Input.Changed:Connect(function()
  21. if Input.UserInputState == Enum.UserInputState.End then
  22. Dragging = false
  23. end
  24. end)
  25. end
  26. end)
  27.  
  28. ClickObject.InputChanged:Connect(function(Input)
  29. if Input.UserInputType == Enum.UserInputType.MouseMovement or Input.UserInputType == Enum.UserInputType.Touch then
  30. DragInput = Input
  31. end
  32. end)
  33.  
  34. UserInputService.InputChanged:Connect(function(Input)
  35. if Input == DragInput and Dragging then
  36. local Delta = Input.Position - DragStart
  37. Object.Position = UDim2.new(StartPosition.X.Scale, StartPosition.X.Offset + Delta.X, StartPosition.Y.Scale, StartPosition.Y.Offset + Delta.Y)
  38. end
  39. end)
  40. end
  41.  
  42. function Library:CreateWindow(Config, Parent)
  43. local WindowInit = {}
  44. local Folder = game:GetObjects("rbxassetid://7141683860")[1]
  45. local Screen = Folder.NOOBHUB:Clone()
  46. local Main = Screen.Main
  47. local Holder = Main.Holder
  48. local Topbar = Main.Topbar
  49. local TContainer = Holder.TContainer
  50. local TBContainer = Holder.TBContainer.Holder
  51. -- idk probably fix for exploits that dont have this function
  52. if syn and syn.protect_gui then
  53. syn.protect_gui(Screen)
  54. end
  55.  
  56. Screen.Name = HttpService:GenerateGUID(false)
  57. Screen.Parent = Parent
  58. Topbar.WindowName.Text = Config.WindowName
  59.  
  60. MakeDraggable(Topbar,Main)
  61. local function CloseAll()
  62. for _,Tab in pairs(TContainer:GetChildren()) do
  63. if Tab:IsA("ScrollingFrame") then
  64. Tab.Visible = false
  65. end
  66. end
  67. end
  68. local function ResetAll()
  69. for _,TabButton in pairs(TBContainer:GetChildren()) do
  70. if TabButton:IsA("TextButton") then
  71. TabButton.BackgroundTransparency = 1
  72. end
  73. end
  74. for _,TabButton in pairs(TBContainer:GetChildren()) do
  75. if TabButton:IsA("TextButton") then
  76. TabButton.Size = UDim2.new(0,480 / Library.TabCount,1,0)
  77. end
  78. end
  79. for _,Pallete in pairs(Screen:GetChildren()) do
  80. if Pallete:IsA("Frame") and Pallete.Name ~= "Main" then
  81. Pallete.Visible = false
  82. end
  83. end
  84. end
  85. local function KeepFirst()
  86. for _,Tab in pairs(TContainer:GetChildren()) do
  87. if Tab:IsA("ScrollingFrame") then
  88. if Tab.Name == Library.FirstTab .. " T" then
  89. Tab.Visible = true
  90. else
  91. Tab.Visible = false
  92. end
  93. end
  94. end
  95. for _,TabButton in pairs(TBContainer:GetChildren()) do
  96. if TabButton:IsA("TextButton") then
  97. if TabButton.Name == Library.FirstTab .. " TB" then
  98. TabButton.BackgroundTransparency = 0
  99. else
  100. TabButton.BackgroundTransparency = 1
  101. end
  102. end
  103. end
  104. end
  105. local function Toggle(State)
  106. if State then
  107. Main.Visible = true
  108. elseif not State then
  109. for _,Pallete in pairs(Screen:GetChildren()) do
  110. if Pallete:IsA("Frame") and Pallete.Name ~= "Main" then
  111. Pallete.Visible = false
  112. end
  113. end
  114. Screen.ToolTip.Visible = false
  115. Main.Visible = false
  116. end
  117. Library.Toggle = State
  118. end
  119. local function ChangeColor(Color)
  120. Config.Color = Color
  121. for i, v in pairs(Library.ColorTable) do
  122. if v.BackgroundColor3 ~= Color3.fromRGB(50, 50, 50) then
  123. v.BackgroundColor3 = Color
  124. end
  125. end
  126. end
  127.  
  128. function WindowInit:Toggle(State)
  129. Toggle(State)
  130. end
  131.  
  132. function WindowInit:ChangeColor(Color)
  133. ChangeColor(Color)
  134. end
  135.  
  136. function WindowInit:SetBackground(ImageId)
  137. Holder.Image = "rbxassetid://" .. ImageId
  138. end
  139.  
  140. function WindowInit:SetBackgroundColor(Color)
  141. Holder.ImageColor3 = Color
  142. end
  143. function WindowInit:SetBackgroundTransparency(Transparency)
  144. Holder.ImageTransparency = Transparency
  145. end
  146.  
  147. function WindowInit:SetTileOffset(Offset)
  148. Holder.TileSize = UDim2.new(0,Offset,0,Offset)
  149. end
  150. function WindowInit:SetTileScale(Scale)
  151. Holder.TileSize = UDim2.new(Scale,0,Scale,0)
  152. end
  153.  
  154. RunService.RenderStepped:Connect(function()
  155. if Library.Toggle then
  156. Screen.ToolTip.Position = UDim2.new(0,UserInputService:GetMouseLocation().X + 10,0,UserInputService:GetMouseLocation().Y - 5)
  157. end
  158. end)
  159.  
  160. function WindowInit:CreateTab(Name)
  161. local TabInit = {}
  162. local Tab = Folder.Tab:Clone()
  163. local TabButton = Folder.TabButton:Clone()
  164.  
  165. Tab.Name = Name .. " T"
  166. Tab.Parent = TContainer
  167.  
  168. TabButton.Name = Name .. " TB"
  169. TabButton.Parent = TBContainer
  170. TabButton.Title.Text = Name
  171. TabButton.BackgroundColor3 = Config.Color
  172.  
  173. table.insert(Library.ColorTable, TabButton)
  174. Library.TabCount = Library.TabCount + 1
  175. if Library.TabCount == 1 then
  176. Library.FirstTab = Name
  177. end
  178.  
  179. CloseAll()
  180. ResetAll()
  181. KeepFirst()
  182.  
  183. local function GetSide(Longest)
  184. if Longest then
  185. if Tab.LeftSide.ListLayout.AbsoluteContentSize.Y > Tab.RightSide.ListLayout.AbsoluteContentSize.Y then
  186. return Tab.LeftSide
  187. else
  188. return Tab.RightSide
  189. end
  190. else
  191. if Tab.LeftSide.ListLayout.AbsoluteContentSize.Y > Tab.RightSide.ListLayout.AbsoluteContentSize.Y then
  192. return Tab.RightSide
  193. else
  194. return Tab.LeftSide
  195. end
  196. end
  197. end
  198.  
  199. TabButton.MouseButton1Click:Connect(function()
  200. CloseAll()
  201. ResetAll()
  202. Tab.Visible = true
  203. TabButton.BackgroundTransparency = 0
  204. end)
  205.  
  206. Tab.LeftSide.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  207. if GetSide(true).Name == Tab.LeftSide.Name then
  208. Tab.CanvasSize = UDim2.new(0,0,0,Tab.LeftSide.ListLayout.AbsoluteContentSize.Y + 15)
  209. else
  210. Tab.CanvasSize = UDim2.new(0,0,0,Tab.RightSide.ListLayout.AbsoluteContentSize.Y + 15)
  211. end
  212. end)
  213. Tab.RightSide.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  214. if GetSide(true).Name == Tab.LeftSide.Name then
  215. Tab.CanvasSize = UDim2.new(0,0,0,Tab.LeftSide.ListLayout.AbsoluteContentSize.Y + 15)
  216. else
  217. Tab.CanvasSize = UDim2.new(0,0,0,Tab.RightSide.ListLayout.AbsoluteContentSize.Y + 15)
  218. end
  219. end)
  220.  
  221. function TabInit:CreateSection(Name)
  222. local SectionInit = {}
  223. local Section = Folder.Section:Clone()
  224. Section.Name = Name .. " S"
  225. Section.Parent = GetSide(false)
  226.  
  227. Section.Title.Text = Name
  228. Section.Title.Size = UDim2.new(0,Section.Title.TextBounds.X + 10,0,2)
  229.  
  230. Section.Container.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  231. Section.Size = UDim2.new(1,0,0,Section.Container.ListLayout.AbsoluteContentSize.Y + 15)
  232. end)
  233.  
  234. function SectionInit:CreateLabel(Name)
  235. local LabelInit = {}
  236. local Label = Folder.Label:Clone()
  237. Label.Name = Name .. " L"
  238. Label.Parent = Section.Container
  239. Label.Text = Name
  240. Label.Size = UDim2.new(1,-10,0,Label.TextBounds.Y)
  241. function LabelInit:UpdateText(Text)
  242. Label.Text = Text
  243. Label.Size = UDim2.new(1,-10,0,Label.TextBounds.Y)
  244. end
  245. return LabelInit
  246. end
  247. function SectionInit:CreateButton(Name, Callback)
  248. local ButtonInit = {}
  249. local Button = Folder.Button:Clone()
  250. Button.Name = Name .. " B"
  251. Button.Parent = Section.Container
  252. Button.Title.Text = Name
  253. Button.Size = UDim2.new(1,-10,0,Button.Title.TextBounds.Y + 5)
  254. table.insert(Library.ColorTable, Button)
  255.  
  256. Button.MouseButton1Down:Connect(function()
  257. Button.BackgroundColor3 = Config.Color
  258. end)
  259.  
  260. Button.MouseButton1Up:Connect(function()
  261. Button.BackgroundColor3 = Color3.fromRGB(50,50,50)
  262. end)
  263.  
  264. Button.MouseLeave:Connect(function()
  265. Button.BackgroundColor3 = Color3.fromRGB(50,50,50)
  266. end)
  267.  
  268. Button.MouseButton1Click:Connect(function()
  269. Callback()
  270. end)
  271.  
  272. function ButtonInit:AddToolTip(Name)
  273. if tostring(Name):gsub(" ", "") ~= "" then
  274. Button.MouseEnter:Connect(function()
  275. Screen.ToolTip.Text = Name
  276. Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  277. Screen.ToolTip.Visible = true
  278. end)
  279.  
  280. Button.MouseLeave:Connect(function()
  281. Screen.ToolTip.Visible = false
  282. end)
  283. end
  284. end
  285.  
  286. return ButtonInit
  287. end
  288. function SectionInit:CreateTextBox(Name, PlaceHolder, NumbersOnly, Callback)
  289. local TextBoxInit = {}
  290. local TextBox = Folder.TextBox:Clone()
  291. TextBox.Name = Name .. " T"
  292. TextBox.Parent = Section.Container
  293. TextBox.Title.Text = Name
  294. TextBox.Background.Input.PlaceholderText = PlaceHolder
  295. TextBox.Title.Size = UDim2.new(1,0,0,TextBox.Title.TextBounds.Y + 5)
  296. TextBox.Size = UDim2.new(1,-10,0,TextBox.Title.TextBounds.Y + 25)
  297.  
  298. TextBox.Background.Input.FocusLost:Connect(function()
  299. if NumbersOnly and not tonumber(TextBox.Background.Input.Text) then
  300. Callback(tonumber(TextBox.Background.Input.Text))
  301. --TextBox.Background.Input.Text = ""
  302. else
  303. Callback(TextBox.Background.Input.Text)
  304. --TextBox.Background.Input.Text = ""
  305. end
  306. end)
  307. function TextBoxInit:SetValue(String)
  308. Callback(String)
  309. TextBox.Background.Input.Text = String
  310. end
  311. function TextBoxInit:AddToolTip(Name)
  312. if tostring(Name):gsub(" ", "") ~= "" then
  313. TextBox.MouseEnter:Connect(function()
  314. Screen.ToolTip.Text = Name
  315. Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  316. Screen.ToolTip.Visible = true
  317. end)
  318.  
  319. TextBox.MouseLeave:Connect(function()
  320. Screen.ToolTip.Visible = false
  321. end)
  322. end
  323. end
  324. return TextBoxInit
  325. end
  326. function SectionInit:CreateToggle(Name, Default, Callback)
  327. local DefaultLocal = Default or false
  328. local ToggleInit = {}
  329. local Toggle = Folder.Toggle:Clone()
  330. Toggle.Name = Name .. " T"
  331. Toggle.Parent = Section.Container
  332. Toggle.Title.Text = Name
  333. Toggle.Size = UDim2.new(1,-10,0,Toggle.Title.TextBounds.Y + 5)
  334.  
  335. table.insert(Library.ColorTable, Toggle.Toggle)
  336. local ToggleState = false
  337.  
  338. local function SetState(State)
  339. if State then
  340. Toggle.Toggle.BackgroundColor3 = Config.Color
  341. elseif not State then
  342. Toggle.Toggle.BackgroundColor3 = Color3.fromRGB(50,50,50)
  343. end
  344. ToggleState = State
  345. Callback(State)
  346. end
  347.  
  348. Toggle.MouseButton1Click:Connect(function()
  349. ToggleState = not ToggleState
  350. SetState(ToggleState)
  351. end)
  352.  
  353. function ToggleInit:AddToolTip(Name)
  354. if tostring(Name):gsub(" ", "") ~= "" then
  355. Toggle.MouseEnter:Connect(function()
  356. Screen.ToolTip.Text = Name
  357. Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  358. Screen.ToolTip.Visible = true
  359. end)
  360.  
  361. Toggle.MouseLeave:Connect(function()
  362. Screen.ToolTip.Visible = false
  363. end)
  364. end
  365. end
  366.  
  367. if Default == nil then
  368. function ToggleInit:SetState(State)
  369. SetState(State)
  370. end
  371. else
  372. SetState(DefaultLocal)
  373. end
  374.  
  375. function ToggleInit:GetState(State)
  376. return ToggleState
  377. end
  378.  
  379. function ToggleInit:CreateKeybind(Bind,Callback)
  380. local KeybindInit = {}
  381. Bind = Bind or "NONE"
  382.  
  383. local WaitingForBind = false
  384. local Selected = Bind
  385. local Blacklist = {"W","A","S","D","Slash","Tab","Backspace","Escape","Space","Delete","Unknown","Backquote"}
  386.  
  387. Toggle.Keybind.Visible = true
  388. Toggle.Keybind.Text = "[ " .. Bind .. " ]"
  389.  
  390. Toggle.Keybind.MouseButton1Click:Connect(function()
  391. Toggle.Keybind.Text = "[ ... ]"
  392. WaitingForBind = true
  393. end)
  394.  
  395. Toggle.Keybind:GetPropertyChangedSignal("TextBounds"):Connect(function()
  396. Toggle.Keybind.Size = UDim2.new(0,Toggle.Keybind.TextBounds.X,1,0)
  397. Toggle.Title.Size = UDim2.new(1,-Toggle.Keybind.Size.X.Offset - 15,1,0)
  398. end)
  399.  
  400. UserInputService.InputBegan:Connect(function(Input)
  401. if WaitingForBind and Input.UserInputType == Enum.UserInputType.Keyboard then
  402. local Key = tostring(Input.KeyCode):gsub("Enum.KeyCode.", "")
  403. if not table.find(Blacklist, Key) then
  404. Toggle.Keybind.Text = "[ " .. Key .. " ]"
  405. Selected = Key
  406. else
  407. Toggle.Keybind.Text = "[ NONE ]"
  408. Selected = "NONE"
  409. end
  410. WaitingForBind = false
  411. elseif Input.UserInputType == Enum.UserInputType.Keyboard then
  412. local Key = tostring(Input.KeyCode):gsub("Enum.KeyCode.", "")
  413. if Key == Selected then
  414. ToggleState = not ToggleState
  415. SetState(ToggleState)
  416. if Callback then
  417. Callback(Key)
  418. end
  419. end
  420. end
  421. end)
  422.  
  423. function KeybindInit:SetBind(Key)
  424. Toggle.Keybind.Text = "[ " .. Key .. " ]"
  425. Selected = Key
  426. end
  427.  
  428. function KeybindInit:GetBind()
  429. return Selected
  430. end
  431.  
  432. return KeybindInit
  433. end
  434. return ToggleInit
  435. end
  436. function SectionInit:CreateSlider(Name, Min, Max, Default, Precise, Callback)
  437. local DefaultLocal = Default or 50
  438. local SliderInit = {}
  439. local Slider = Folder.Slider:Clone()
  440. Slider.Name = Name .. " S"
  441. Slider.Parent = Section.Container
  442.  
  443. Slider.Title.Text = Name
  444. Slider.Slider.Bar.Size = UDim2.new(Min / Max,0,1,0)
  445. Slider.Slider.Bar.BackgroundColor3 = Config.Color
  446. Slider.Value.PlaceholderText = tostring(Min / Max)
  447. Slider.Title.Size = UDim2.new(1,0,0,Slider.Title.TextBounds.Y + 5)
  448. Slider.Size = UDim2.new(1,-10,0,Slider.Title.TextBounds.Y + 15)
  449. table.insert(Library.ColorTable, Slider.Slider.Bar)
  450.  
  451. local GlobalSliderValue = 0
  452. local Dragging = false
  453. local function Sliding(Input)
  454. local Position = UDim2.new(math.clamp((Input.Position.X - Slider.Slider.AbsolutePosition.X) / Slider.Slider.AbsoluteSize.X,0,1),0,1,0)
  455. Slider.Slider.Bar.Size = Position
  456. local SliderPrecise = ((Position.X.Scale * Max) / Max) * (Max - Min) + Min
  457. local SliderNonPrecise = math.floor(((Position.X.Scale * Max) / Max) * (Max - Min) + Min)
  458. local SliderValue = Precise and SliderNonPrecise or SliderPrecise
  459. SliderValue = tonumber(string.format("%.2f", SliderValue))
  460. GlobalSliderValue = SliderValue
  461. Slider.Value.PlaceholderText = tostring(SliderValue)
  462. Callback(GlobalSliderValue)
  463. end
  464. local function SetValue(Value)
  465. GlobalSliderValue = Value
  466. Slider.Slider.Bar.Size = UDim2.new(Value / Max,0,1,0)
  467. Slider.Value.PlaceholderText = Value
  468. Callback(Value)
  469. end
  470. Slider.Value.FocusLost:Connect(function()
  471. if not tonumber(Slider.Value.Text) then
  472. Slider.Value.Text = GlobalSliderValue
  473. elseif Slider.Value.Text == "" or tonumber(Slider.Value.Text) <= Min then
  474. Slider.Value.Text = Min
  475. elseif Slider.Value.Text == "" or tonumber(Slider.Value.Text) >= Max then
  476. Slider.Value.Text = Max
  477. end
  478.  
  479. GlobalSliderValue = Slider.Value.Text
  480. Slider.Slider.Bar.Size = UDim2.new(Slider.Value.Text / Max,0,1,0)
  481. Slider.Value.PlaceholderText = Slider.Value.Text
  482. Callback(tonumber(Slider.Value.Text))
  483. Slider.Value.Text = ""
  484. end)
  485.  
  486. Slider.InputBegan:Connect(function(Input)
  487. if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  488. Sliding(Input)
  489. Dragging = true
  490. end
  491. end)
  492.  
  493. Slider.InputEnded:Connect(function(Input)
  494. if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  495. Dragging = false
  496. end
  497. end)
  498.  
  499. UserInputService.InputBegan:Connect(function(Input)
  500. if Input.KeyCode == Enum.KeyCode.LeftControl then
  501. Slider.Value.ZIndex = 4
  502. end
  503. end)
  504.  
  505. UserInputService.InputEnded:Connect(function(Input)
  506. if Input.KeyCode == Enum.KeyCode.LeftControl then
  507. Slider.Value.ZIndex = 3
  508. end
  509. end)
  510.  
  511. UserInputService.InputChanged:Connect(function(Input)
  512. if Dragging and Input.UserInputType == Enum.UserInputType.MouseMovement then
  513. Sliding(Input)
  514. end
  515. end)
  516.  
  517. function SliderInit:AddToolTip(Name)
  518. if tostring(Name):gsub(" ", "") ~= "" then
  519. Slider.MouseEnter:Connect(function()
  520. Screen.ToolTip.Text = Name
  521. Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  522. Screen.ToolTip.Visible = true
  523. end)
  524.  
  525. Slider.MouseLeave:Connect(function()
  526. Screen.ToolTip.Visible = false
  527. end)
  528. end
  529. end
  530.  
  531. if Default == nil then
  532. function SliderInit:SetValue(Value)
  533. GlobalSliderValue = Value
  534. Slider.Slider.Bar.Size = UDim2.new(Value / Max,0,1,0)
  535. Slider.Value.PlaceholderText = Value
  536. Callback(Value)
  537. end
  538. else
  539. SetValue(DefaultLocal)
  540. end
  541.  
  542. function SliderInit:GetValue(Value)
  543. return GlobalSliderValue
  544. end
  545.  
  546. return SliderInit
  547. end
  548. function SectionInit:CreateDropdown(Name, OptionTable, Callback, InitialValue)
  549. local DropdownInit = {}
  550. local Dropdown = Folder.Dropdown:Clone()
  551. Dropdown.Name = Name .. " D"
  552. Dropdown.Parent = Section.Container
  553.  
  554. Dropdown.Title.Text = Name
  555. Dropdown.Title.Size = UDim2.new(1,0,0,Dropdown.Title.TextBounds.Y + 5)
  556. Dropdown.Container.Position = UDim2.new(0,0,0,Dropdown.Title.TextBounds.Y + 5)
  557. Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Title.TextBounds.Y + 25)
  558.  
  559. local DropdownToggle = false
  560.  
  561. Dropdown.MouseButton1Click:Connect(function()
  562. DropdownToggle = not DropdownToggle
  563. if DropdownToggle then
  564. Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y + Dropdown.Title.TextBounds.Y + 30)
  565. Dropdown.Container.Holder.Visible = true
  566. else
  567. Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Title.TextBounds.Y + 25)
  568. Dropdown.Container.Holder.Visible = false
  569. end
  570. end)
  571.  
  572. for _,OptionName in pairs(OptionTable) do
  573. local Option = Folder.Option:Clone()
  574. Option.Name = OptionName
  575. Option.Parent = Dropdown.Container.Holder.Container
  576.  
  577. Option.Title.Text = OptionName
  578. Option.BackgroundColor3 = Config.Color
  579. Option.Size = UDim2.new(1,0,0,Option.Title.TextBounds.Y + 5)
  580. Dropdown.Container.Holder.Size = UDim2.new(1,-5,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y)
  581. table.insert(Library.ColorTable, Option)
  582.  
  583. Option.MouseButton1Down:Connect(function()
  584. Option.BackgroundTransparency = 0
  585. end)
  586.  
  587. Option.MouseButton1Up:Connect(function()
  588. Option.BackgroundTransparency = 1
  589. end)
  590.  
  591. Option.MouseLeave:Connect(function()
  592. Option.BackgroundTransparency = 1
  593. end)
  594.  
  595. Option.MouseButton1Click:Connect(function()
  596. Dropdown.Container.Value.Text = OptionName
  597. Callback(OptionName)
  598. end)
  599. end
  600. function DropdownInit:AddToolTip(Name)
  601. if tostring(Name):gsub(" ", "") ~= "" then
  602. Dropdown.MouseEnter:Connect(function()
  603. Screen.ToolTip.Text = Name
  604. Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  605. Screen.ToolTip.Visible = true
  606. end)
  607.  
  608. Dropdown.MouseLeave:Connect(function()
  609. Screen.ToolTip.Visible = false
  610. end)
  611. end
  612. end
  613.  
  614. function DropdownInit:GetOption()
  615. return Dropdown.Container.Value.Text
  616. end
  617. function DropdownInit:SetOption(Name)
  618. for _,Option in pairs(Dropdown.Container.Holder.Container:GetChildren()) do
  619. if Option:IsA("TextButton") and string.find(Option.Name, Name) then
  620. Dropdown.Container.Value.Text = Option.Name
  621. Callback(Name)
  622. end
  623. end
  624. end
  625. function DropdownInit:RemoveOption(Name)
  626. for _,Option in pairs(Dropdown.Container.Holder.Container:GetChildren()) do
  627. if Option:IsA("TextButton") and string.find(Option.Name, Name) then
  628. Option:Destroy()
  629. end
  630. end
  631. Dropdown.Container.Holder.Size = UDim2.new(1,-5,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y)
  632. Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y + Dropdown.Title.TextBounds.Y + 30)
  633. end
  634. function DropdownInit:ClearOptions()
  635. for _, Option in pairs(Dropdown.Container.Holder.Container:GetChildren()) do
  636. if Option:IsA("TextButton") then
  637. Option:Destroy()
  638. end
  639. end
  640. Dropdown.Container.Holder.Size = UDim2.new(1,-5,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y)
  641. Dropdown.Size = UDim2.new(1,-10,0,Dropdown.Container.Holder.Container.ListLayout.AbsoluteContentSize.Y + Dropdown.Title.TextBounds.Y + 30)
  642. end
  643. if InitialValue then
  644. DropdownInit:SetOption(InitialValue)
  645. end
  646. return DropdownInit
  647. end
  648. function SectionInit:CreateColorpicker(Name,Callback)
  649. local ColorpickerInit = {}
  650. local Colorpicker = Folder.Colorpicker:Clone()
  651. local Pallete = Folder.Pallete:Clone()
  652.  
  653. Colorpicker.Name = Name .. " CP"
  654. Colorpicker.Parent = Section.Container
  655. Colorpicker.Title.Text = Name
  656. Colorpicker.Size = UDim2.new(1,-10,0,Colorpicker.Title.TextBounds.Y + 5)
  657.  
  658. Pallete.Name = Name .. " P"
  659. Pallete.Parent = Screen
  660.  
  661. local ColorTable = {
  662. Hue = 1,
  663. Saturation = 0,
  664. Value = 0
  665. }
  666. local ColorRender = nil
  667. local HueRender = nil
  668. local ColorpickerRender = nil
  669. local function UpdateColor()
  670. Colorpicker.Color.BackgroundColor3 = Color3.fromHSV(ColorTable.Hue,ColorTable.Saturation,ColorTable.Value)
  671. Pallete.GradientPallete.BackgroundColor3 = Color3.fromHSV(ColorTable.Hue,1,1)
  672. Pallete.Input.InputBox.PlaceholderText = "RGB: " .. math.round(Colorpicker.Color.BackgroundColor3.R* 255) .. "," .. math.round(Colorpicker.Color.BackgroundColor3.G * 255) .. "," .. math.round(Colorpicker.Color.BackgroundColor3.B * 255)
  673. Callback(Colorpicker.Color.BackgroundColor3)
  674. end
  675.  
  676. Colorpicker.MouseButton1Click:Connect(function()
  677. if not Pallete.Visible then
  678. ColorpickerRender = RunService.RenderStepped:Connect(function()
  679. Pallete.Position = UDim2.new(0,Colorpicker.Color.AbsolutePosition.X - 129,0,Colorpicker.Color.AbsolutePosition.Y + 52)
  680. end)
  681. Pallete.Visible = true
  682. else
  683. Pallete.Visible = false
  684. ColorpickerRender:Disconnect()
  685. end
  686. end)
  687.  
  688. Pallete.GradientPallete.InputBegan:Connect(function(Input)
  689. if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  690. if ColorRender then
  691. ColorRender:Disconnect()
  692. end
  693. ColorRender = RunService.RenderStepped:Connect(function()
  694. local Mouse = UserInputService:GetMouseLocation()
  695. local ColorX = math.clamp(Mouse.X - Pallete.GradientPallete.AbsolutePosition.X, 0, Pallete.GradientPallete.AbsoluteSize.X) / Pallete.GradientPallete.AbsoluteSize.X
  696. local ColorY = math.clamp((Mouse.Y - 37) - Pallete.GradientPallete.AbsolutePosition.Y, 0, Pallete.GradientPallete.AbsoluteSize.Y) / Pallete.GradientPallete.AbsoluteSize.Y
  697. Pallete.GradientPallete.Dot.Position = UDim2.new(ColorX,0,ColorY,0)
  698. ColorTable.Saturation = ColorX
  699. ColorTable.Value = 1 - ColorY
  700. UpdateColor()
  701. end)
  702. end
  703. end)
  704.  
  705. Pallete.GradientPallete.InputEnded:Connect(function(Input)
  706. if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  707. if ColorRender then
  708. ColorRender:Disconnect()
  709. end
  710. end
  711. end)
  712.  
  713. Pallete.ColorSlider.InputBegan:Connect(function(Input)
  714. if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  715. if HueRender then
  716. HueRender:Disconnect()
  717. end
  718. HueRender = RunService.RenderStepped:Connect(function()
  719. local Mouse = UserInputService:GetMouseLocation()
  720. local HueX = math.clamp(Mouse.X - Pallete.ColorSlider.AbsolutePosition.X, 0, Pallete.ColorSlider.AbsoluteSize.X) / Pallete.ColorSlider.AbsoluteSize.X
  721. ColorTable.Hue = 1 - HueX
  722. UpdateColor()
  723. end)
  724. end
  725. end)
  726.  
  727. Pallete.ColorSlider.InputEnded:Connect(function(Input)
  728. if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  729. if HueRender then
  730. HueRender:Disconnect()
  731. end
  732. end
  733. end)
  734.  
  735. function ColorpickerInit:UpdateColor(Color)
  736. local Hue, Saturation, Value = Color:ToHSV()
  737. Colorpicker.Color.BackgroundColor3 = Color3.fromHSV(Hue,Saturation,Value)
  738. Pallete.GradientPallete.BackgroundColor3 = Color3.fromHSV(Hue,1,1)
  739. Pallete.Input.InputBox.PlaceholderText = "RGB: " .. math.round(Colorpicker.Color.BackgroundColor3.R* 255) .. "," .. math.round(Colorpicker.Color.BackgroundColor3.G * 255) .. "," .. math.round(Colorpicker.Color.BackgroundColor3.B * 255)
  740. ColorTable = {
  741. Hue = Hue,
  742. Saturation = Saturation,
  743. Value = Value
  744. }
  745. Callback(Color)
  746. end
  747.  
  748. Pallete.Input.InputBox.FocusLost:Connect(function(Enter)
  749. if Enter then
  750. local ColorString = string.split(string.gsub(Pallete.Input.InputBox.Text," ", ""), ",")
  751. ColorpickerInit:UpdateColor(Color3.fromRGB(ColorString[1],ColorString[2],ColorString[3]))
  752. Pallete.Input.InputBox.Text = ""
  753. end
  754. end)
  755.  
  756. function ColorpickerInit:AddToolTip(Name)
  757. if tostring(Name):gsub(" ", "") ~= "" then
  758. Colorpicker.MouseEnter:Connect(function()
  759. Screen.ToolTip.Text = Name
  760. Screen.ToolTip.Size = UDim2.new(0,Screen.ToolTip.TextBounds.X + 5,0,Screen.ToolTip.TextBounds.Y + 5)
  761. Screen.ToolTip.Visible = true
  762. end)
  763.  
  764. Colorpicker.MouseLeave:Connect(function()
  765. Screen.ToolTip.Visible = false
  766. end)
  767. end
  768. end
  769.  
  770. return ColorpickerInit
  771. end
  772. return SectionInit
  773. end
  774. return TabInit
  775. end
  776. return WindowInit
  777. end
  778.  
  779. return Library
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement