Advertisement
matekaOSF2

uiLib

Dec 22nd, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.17 KB | None | 0 0
  1. local library = {count = 0, queue = {}, callbacks = {}, rainbowtable = {}, toggled = true, binds = {}};
  2. local defaults; do
  3. local dragger = {}; do
  4. local mouse = game:GetService("Players").LocalPlayer:GetMouse();
  5. local inputService = game:GetService('UserInputService');
  6. local heartbeat = game:GetService("RunService").Heartbeat;
  7. -- // credits to Ririchi / Inori for this cute drag function :)
  8. function dragger.new(frame)
  9. local s, event = pcall(function()
  10. return frame.MouseEnter
  11. end)
  12.  
  13. if s then
  14. frame.Active = true;
  15.  
  16. event:connect(function()
  17. local input = frame.InputBegan:connect(function(key)
  18. if key.UserInputType == Enum.UserInputType.MouseButton1 then
  19. local objectPosition = Vector2.new(mouse.X - frame.AbsolutePosition.X, mouse.Y - frame.AbsolutePosition.Y);
  20. while heartbeat:wait() and inputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
  21. pcall(function()
  22. frame:TweenPosition(UDim2.new(0, mouse.X - objectPosition.X + (frame.Size.X.Offset * frame.AnchorPoint.X), 0, mouse.Y - objectPosition.Y + (frame.Size.Y.Offset * frame.AnchorPoint.Y)), 'Out', 'Linear', 0.1, true);
  23. end)
  24. end
  25. end
  26. end)
  27.  
  28. local leave;
  29. leave = frame.MouseLeave:connect(function()
  30. input:disconnect();
  31. leave:disconnect();
  32. end)
  33. end)
  34. end
  35. end
  36.  
  37. game:GetService('UserInputService').InputBegan:connect(function(key, gpe)
  38. if (not gpe) then
  39. if key.KeyCode == Enum.KeyCode.F15 then
  40. library.toggled = not library.toggled;
  41. for i, data in next, library.queue do
  42. local pos = (library.toggled and data.p or UDim2.new(-1, 0, -0.5,0))
  43. data.w:TweenPosition(pos, (library.toggled and 'Out' or 'In'), 'Quad', 0.15, true)
  44. wait();
  45. end
  46. end
  47. end
  48. end)
  49. end
  50.  
  51. local types = {}; do
  52. types.__index = types;
  53. function types.window(name, options)
  54. library.count = library.count + 1
  55. local newWindow = library:Create('Frame', {
  56. Name = name;
  57. Size = UDim2.new(0, 190, 0, 30);
  58. BackgroundColor3 = options.topcolor;
  59. BorderSizePixel = 0;
  60. Parent = library.container;
  61. Position = UDim2.new(0, (15 + (200 * library.count) - 200), 0, 0);
  62. ZIndex = 3;
  63. library:Create('TextLabel', {
  64. Text = name;
  65. Size = UDim2.new(1, -10, 1, 0);
  66. Position = UDim2.new(0, 5, 0, 0);
  67. BackgroundTransparency = 1;
  68. Font = Enum.Font.Code;
  69. TextSize = options.titlesize;
  70. Font = options.titlefont;
  71. TextColor3 = options.titletextcolor;
  72. TextStrokeTransparency = library.options.titlestroke;
  73. TextStrokeColor3 = library.options.titlestrokecolor;
  74. ZIndex = 3;
  75. });
  76. library:Create("TextButton", {
  77. Size = UDim2.new(0, 30, 0, 30);
  78. Position = UDim2.new(1, -35, 0, 0);
  79. BackgroundTransparency = 1;
  80. Text = "-";
  81. TextSize = options.titlesize;
  82. Font = options.titlefont;--Enum.Font.Code;
  83. Name = 'window_toggle';
  84. TextColor3 = options.titletextcolor;
  85. TextStrokeTransparency = library.options.titlestroke;
  86. TextStrokeColor3 = library.options.titlestrokecolor;
  87. ZIndex = 3;
  88. });
  89. library:Create("Frame", {
  90. Name = 'Underline';
  91. Size = UDim2.new(1, 0, 0, 2);
  92. Position = UDim2.new(0, 0, 1, -2);
  93. BackgroundColor3 = (options.underlinecolor ~= "rainbow" and options.underlinecolor or Color3.new());
  94. BorderSizePixel = 0;
  95. ZIndex = 3;
  96. });
  97. library:Create('Frame', {
  98. Name = 'container';
  99. Position = UDim2.new(0, 0, 1, 0);
  100. Size = UDim2.new(1, 0, 0, 0);
  101. BorderSizePixel = 0;
  102. BackgroundColor3 = options.bgcolor;
  103. ClipsDescendants = false;
  104. library:Create('UIListLayout', {
  105. Name = 'List';
  106. SortOrder = Enum.SortOrder.LayoutOrder;
  107. })
  108. });
  109. })
  110.  
  111. if options.underlinecolor == "rainbow" then
  112. table.insert(library.rainbowtable, newWindow:FindFirstChild('Underline'))
  113. end
  114.  
  115. local window = setmetatable({
  116. count = 0;
  117. object = newWindow;
  118. container = newWindow.container;
  119. toggled = true;
  120. flags = {};
  121.  
  122. }, types)
  123.  
  124. table.insert(library.queue, {
  125. w = window.object;
  126. p = window.object.Position;
  127. })
  128.  
  129. newWindow:FindFirstChild("window_toggle").MouseButton1Click:connect(function()
  130. window.toggled = not window.toggled;
  131. newWindow:FindFirstChild("window_toggle").Text = (window.toggled and "+" or "-")
  132. if (not window.toggled) then
  133. window.container.ClipsDescendants = true;
  134. end
  135. wait();
  136. local y = 0;
  137. for i, v in next, window.container:GetChildren() do
  138. if (not v:IsA('UIListLayout')) then
  139. y = y + v.AbsoluteSize.Y;
  140. end
  141. end
  142.  
  143. local targetSize = window.toggled and UDim2.new(1, 0, 0, y+5) or UDim2.new(1, 0, 0, 0);
  144. local targetDirection = window.toggled and "In" or "Out"
  145.  
  146. window.container:TweenSize(targetSize, targetDirection, "Quad", 0.15, true)
  147. wait(.15)
  148. if window.toggled then
  149. window.container.ClipsDescendants = false;
  150. end
  151. end)
  152.  
  153. return window;
  154. end
  155.  
  156. function types:Resize()
  157. local y = 0;
  158. for i, v in next, self.container:GetChildren() do
  159. if (not v:IsA('UIListLayout')) then
  160. y = y + v.AbsoluteSize.Y;
  161. end
  162. end
  163. self.container.Size = UDim2.new(1, 0, 0, y+5)
  164. end
  165.  
  166. function types:GetOrder()
  167. local c = 0;
  168. for i, v in next, self.container:GetChildren() do
  169. if (not v:IsA('UIListLayout')) then
  170. c = c + 1
  171. end
  172. end
  173. return c
  174. end
  175.  
  176. function types:Label(text)
  177. local v = game:GetService'TextService':GetTextSize(text, 18, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  178. local object = library:Create('Frame', {
  179. Size = UDim2.new(1, 0, 0, v.Y + 5);
  180. BackgroundTransparency = 1;
  181. library:Create('TextLabel', {
  182. Size = UDim2.new(1, 0, 1, 0);
  183. Position = UDim2.new(0, 10, 0, 0);
  184. LayoutOrder = self:GetOrder();
  185.  
  186. Text = text;
  187. TextSize = 18;
  188. Font = Enum.Font.SourceSans;
  189. TextColor3 = Color3.fromRGB(255, 255, 255);
  190. BackgroundTransparency = 1;
  191. TextXAlignment = Enum.TextXAlignment.Left;
  192. TextWrapped = true;
  193. });
  194. Parent = self.container
  195. })
  196. self:Resize();
  197. end
  198.  
  199. function types:Toggle(name, options, callback)
  200. local default = options.default or false;
  201. local location = options.location or self.flags;
  202. local flag = options.flag or "";
  203. local callback = callback or function() end;
  204.  
  205. location[flag] = default;
  206.  
  207. local check = library:Create('Frame', {
  208. BackgroundTransparency = 1;
  209. Size = UDim2.new(1, 0, 0, 25);
  210. LayoutOrder = self:GetOrder();
  211. library:Create('TextLabel', {
  212. Name = name;
  213. Text = "\r" .. name;
  214. BackgroundTransparency = 1;
  215. TextColor3 = library.options.textcolor;
  216. Position = UDim2.new(0, 5, 0, 0);
  217. Size = UDim2.new(1, -5, 1, 0);
  218. TextXAlignment = Enum.TextXAlignment.Left;
  219. Font = library.options.font;
  220. TextSize = library.options.fontsize;
  221. TextStrokeTransparency = library.options.textstroke;
  222. TextStrokeColor3 = library.options.strokecolor;
  223. library:Create('TextButton', {
  224. Text = (location[flag] and utf8.char(10003) or "");
  225. Font = library.options.font;
  226. TextSize = library.options.fontsize;
  227. Name = 'Checkmark';
  228. Size = UDim2.new(0, 20, 0, 20);
  229. Position = UDim2.new(1, -25, 0, 4);
  230. TextColor3 = library.options.textcolor;
  231. BackgroundColor3 = library.options.bgcolor;
  232. BorderColor3 = library.options.bordercolor;
  233. TextStrokeTransparency = library.options.textstroke;
  234. TextStrokeColor3 = library.options.strokecolor;
  235. })
  236. });
  237. Parent = self.container;
  238. });
  239.  
  240. local function click(t)
  241. location[flag] = not location[flag];
  242. callback(location[flag])
  243. check:FindFirstChild(name).Checkmark.Text = location[flag] and utf8.char(10003) or "";
  244. end
  245.  
  246. check:FindFirstChild(name).Checkmark.MouseButton1Click:connect(click)
  247. library.callbacks[flag] = click;
  248.  
  249. if location[flag] == true then
  250. callback(location[flag])
  251. end
  252.  
  253. self:Resize();
  254. return {
  255. Set = function(self, b)
  256. location[flag] = b;
  257. callback(location[flag])
  258. check:FindFirstChild(name).Checkmark.Text = location[flag] and utf8.char(10003) or "";
  259. end
  260. }
  261. end
  262.  
  263. function types:Button(name, callback)
  264. callback = callback or function() end;
  265.  
  266. local check = library:Create('Frame', {
  267. BackgroundTransparency = 1;
  268. Size = UDim2.new(1, 0, 0, 25);
  269. LayoutOrder = self:GetOrder();
  270. library:Create('TextButton', {
  271. Name = name;
  272. Text = name;
  273. BackgroundColor3 = library.options.btncolor;
  274. BorderColor3 = library.options.bordercolor;
  275. TextStrokeTransparency = library.options.textstroke;
  276. TextStrokeColor3 = library.options.strokecolor;
  277. TextColor3 = library.options.textcolor;
  278. Position = UDim2.new(0, 5, 0, 5);
  279. Size = UDim2.new(1, -10, 0, 20);
  280. Font = library.options.font;
  281. TextSize = library.options.fontsize;
  282. });
  283. Parent = self.container;
  284. });
  285.  
  286. check:FindFirstChild(name).MouseButton1Click:connect(callback)
  287. self:Resize();
  288.  
  289. return {
  290. Fire = function()
  291. callback();
  292. end
  293. }
  294. end
  295.  
  296. function types:Box(name, options, callback) --type, default, data, location, flag)
  297. local type = options.type or "";
  298. local default = options.default or "";
  299. local data = options.data
  300. local location = options.location or self.flags;
  301. local flag = options.flag or "";
  302. local callback = callback or function() end;
  303. local min = options.min or 0;
  304. local max = options.max or 9e9;
  305.  
  306. if type == 'number' and (not tonumber(default)) then
  307. location[flag] = default;
  308. else
  309. location[flag] = "";
  310. default = "";
  311. end
  312.  
  313. local check = library:Create('Frame', {
  314. BackgroundTransparency = 1;
  315. Size = UDim2.new(1, 0, 0, 25);
  316. LayoutOrder = self:GetOrder();
  317. library:Create('TextLabel', {
  318. Name = name;
  319. Text = "\r" .. name;
  320. BackgroundTransparency = 1;
  321. TextColor3 = library.options.textcolor;
  322. TextStrokeTransparency = library.options.textstroke;
  323. TextStrokeColor3 = library.options.strokecolor;
  324. Position = UDim2.new(0, 5, 0, 0);
  325. Size = UDim2.new(1, -5, 1, 0);
  326. TextXAlignment = Enum.TextXAlignment.Left;
  327. Font = library.options.font;
  328. TextSize = library.options.fontsize;
  329. library:Create('TextBox', {
  330. TextStrokeTransparency = library.options.textstroke;
  331. TextStrokeColor3 = library.options.strokecolor;
  332. Text = tostring(default);
  333. Font = library.options.font;
  334. TextSize = library.options.fontsize;
  335. Name = 'Box';
  336. Size = UDim2.new(0, 60, 0, 20);
  337. Position = UDim2.new(1, -65, 0, 3);
  338. TextColor3 = library.options.textcolor;
  339. BackgroundColor3 = library.options.boxcolor;
  340. BorderColor3 = library.options.bordercolor;
  341. PlaceholderColor3 = library.options.placeholdercolor;
  342. })
  343. });
  344. Parent = self.container;
  345. });
  346.  
  347. local box = check:FindFirstChild(name):FindFirstChild('Box');
  348. box.FocusLost:connect(function(e)
  349. local old = location[flag];
  350. if type == "number" then
  351. local num = tonumber(box.Text)
  352. if (not num) then
  353. box.Text = tonumber(location[flag])
  354. else
  355. location[flag] = math.clamp(num, min, max)
  356. box.Text = tonumber(location[flag])
  357. end
  358. else
  359. location[flag] = tostring(box.Text)
  360. end
  361.  
  362. callback(location[flag], old, e)
  363. end)
  364.  
  365. if type == 'number' then
  366. box:GetPropertyChangedSignal('Text'):connect(function()
  367. box.Text = string.gsub(box.Text, "[%a+]", "");
  368. end)
  369. end
  370.  
  371. self:Resize();
  372. return box
  373. end
  374.  
  375. function types:Bind(name, options, callback)
  376. local location = options.location or self.flags;
  377. local keyboardOnly = options.kbonly or false
  378. local flag = options.flag or "";
  379. local callback = callback or function() end;
  380. local default = options.default;
  381.  
  382. if keyboardOnly and (not tostring(default):find('MouseButton')) then
  383. location[flag] = default
  384. end
  385.  
  386. local banned = {
  387. Return = true;
  388. Space = true;
  389. Tab = true;
  390. Unknown = true;
  391. }
  392.  
  393. local shortNames = {
  394. RightControl = 'RightCtrl';
  395. LeftControl = 'LeftCtrl';
  396. LeftShift = 'LShift';
  397. RightShift = 'RShift';
  398. MouseButton1 = "Mouse1";
  399. MouseButton2 = "Mouse2";
  400. }
  401.  
  402. local allowed = {
  403. MouseButton1 = true;
  404. MouseButton2 = true;
  405. }
  406.  
  407. local nm = (default and (shortNames[default.Name] or default.Name) or "None");
  408. local check = library:Create('Frame', {
  409. BackgroundTransparency = 1;
  410. Size = UDim2.new(1, 0, 0, 30);
  411. LayoutOrder = self:GetOrder();
  412. library:Create('TextLabel', {
  413. Name = name;
  414. Text = "\r" .. name;
  415. BackgroundTransparency = 1;
  416. TextColor3 = library.options.textcolor;
  417. Position = UDim2.new(0, 5, 0, 0);
  418. Size = UDim2.new(1, -5, 1, 0);
  419. TextXAlignment = Enum.TextXAlignment.Left;
  420. Font = library.options.font;
  421. TextSize = library.options.fontsize;
  422. TextStrokeTransparency = library.options.textstroke;
  423. TextStrokeColor3 = library.options.strokecolor;
  424. BorderColor3 = library.options.bordercolor;
  425. BorderSizePixel = 1;
  426. library:Create('TextButton', {
  427. Name = 'Keybind';
  428. Text = nm;
  429. TextStrokeTransparency = library.options.textstroke;
  430. TextStrokeColor3 = library.options.strokecolor;
  431. Font = library.options.font;
  432. TextSize = library.options.fontsize;
  433. Size = UDim2.new(0, 60, 0, 20);
  434. Position = UDim2.new(1, -65, 0, 5);
  435. TextColor3 = library.options.textcolor;
  436. BackgroundColor3 = library.options.bgcolor;
  437. BorderColor3 = library.options.bordercolor;
  438. BorderSizePixel = 1;
  439. })
  440. });
  441. Parent = self.container;
  442. });
  443.  
  444. local button = check:FindFirstChild(name).Keybind;
  445. button.MouseButton1Click:connect(function()
  446. library.binding = true
  447.  
  448. button.Text = "..."
  449. local a, b = game:GetService('UserInputService').InputBegan:wait();
  450. local name = tostring(a.KeyCode.Name);
  451. local typeName = tostring(a.UserInputType.Name);
  452.  
  453. if (a.UserInputType ~= Enum.UserInputType.Keyboard and (allowed[a.UserInputType.Name]) and (not keyboardOnly)) or (a.KeyCode and (not banned[a.KeyCode.Name])) then
  454. local name = (a.UserInputType ~= Enum.UserInputType.Keyboard and a.UserInputType.Name or a.KeyCode.Name);
  455. location[flag] = (a);
  456. button.Text = shortNames[name] or name;
  457.  
  458. else
  459. if (location[flag]) then
  460. if (not pcall(function()
  461. return location[flag].UserInputType
  462. end)) then
  463. local name = tostring(location[flag])
  464. button.Text = shortNames[name] or name
  465. else
  466. local name = (location[flag].UserInputType ~= Enum.UserInputType.Keyboard and location[flag].UserInputType.Name or location[flag].KeyCode.Name);
  467. button.Text = shortNames[name] or name;
  468. end
  469. end
  470. end
  471.  
  472. wait(0.1)
  473. library.binding = false;
  474. end)
  475.  
  476. if location[flag] then
  477. button.Text = shortNames[tostring(location[flag].Name)] or tostring(location[flag].Name)
  478. end
  479.  
  480. library.binds[flag] = {
  481. location = location;
  482. callback = callback;
  483. };
  484.  
  485. self:Resize();
  486. end
  487.  
  488. function types:Section(name)
  489. local order = self:GetOrder();
  490. local determinedSize = UDim2.new(1, 0, 0, 25)
  491. local determinedPos = UDim2.new(0, 0, 0, 4);
  492. local secondarySize = UDim2.new(1, 0, 0, 20);
  493.  
  494. if order == 0 then
  495. determinedSize = UDim2.new(1, 0, 0, 21)
  496. determinedPos = UDim2.new(0, 0, 0, -1);
  497. secondarySize = nil
  498. end
  499.  
  500. local check = library:Create('Frame', {
  501. Name = 'Section';
  502. BackgroundTransparency = 1;
  503. Size = determinedSize;
  504. BackgroundColor3 = library.options.sectncolor;
  505. BorderSizePixel = 0;
  506. LayoutOrder = order;
  507. library:Create('TextLabel', {
  508. Name = 'section_lbl';
  509. Text = name;
  510. BackgroundTransparency = 0;
  511. BorderSizePixel = 0;
  512. BackgroundColor3 = library.options.sectncolor;
  513. TextColor3 = library.options.textcolor;
  514. Position = determinedPos;
  515. Size = (secondarySize or UDim2.new(1, 0, 1, 0));
  516. Font = library.options.font;
  517. TextSize = library.options.fontsize;
  518. TextStrokeTransparency = library.options.textstroke;
  519. TextStrokeColor3 = library.options.strokecolor;
  520. });
  521. Parent = self.container;
  522. });
  523.  
  524. self:Resize();
  525. end
  526.  
  527. function types:Slider(name, options, callback)
  528. local default = options.default or options.min;
  529. local min = options.min or 0;
  530. local max = options.max or 1;
  531. local location = options.location or self.flags;
  532. local precise = options.precise or false -- e.g 0, 1 vs 0, 0.1, 0.2, ...
  533. local flag = options.flag or "";
  534. local callback = callback or function() end
  535.  
  536. location[flag] = default;
  537.  
  538. local check = library:Create('Frame', {
  539. BackgroundTransparency = 1;
  540. Size = UDim2.new(1, 0, 0, 25);
  541. LayoutOrder = self:GetOrder();
  542. library:Create('TextLabel', {
  543. Name = name;
  544. TextStrokeTransparency = library.options.textstroke;
  545. TextStrokeColor3 = library.options.strokecolor;
  546. Text = "\r" .. name;
  547. BackgroundTransparency = 1;
  548. TextColor3 = library.options.textcolor;
  549. Position = UDim2.new(0, 5, 0, 2);
  550. Size = UDim2.new(1, -5, 1, 0);
  551. TextXAlignment = Enum.TextXAlignment.Left;
  552. Font = library.options.font;
  553. TextSize = library.options.fontsize;
  554. library:Create('Frame', {
  555. Name = 'Container';
  556. Size = UDim2.new(0, 60, 0, 20);
  557. Position = UDim2.new(1, -65, 0, 3);
  558. BackgroundTransparency = 1;
  559. --BorderColor3 = library.options.bordercolor;
  560. BorderSizePixel = 0;
  561. library:Create('TextLabel', {
  562. Name = 'ValueLabel';
  563. Text = default;
  564. BackgroundTransparency = 1;
  565. TextColor3 = library.options.textcolor;
  566. Position = UDim2.new(0, -10, 0, 0);
  567. Size = UDim2.new(0, 1, 1, 0);
  568. TextXAlignment = Enum.TextXAlignment.Right;
  569. Font = library.options.font;
  570. TextSize = library.options.fontsize;
  571. TextStrokeTransparency = library.options.textstroke;
  572. TextStrokeColor3 = library.options.strokecolor;
  573. });
  574. library:Create('TextButton', {
  575. Name = 'Button';
  576. Size = UDim2.new(0, 5, 1, -2);
  577. Position = UDim2.new(0, 0, 0, 1);
  578. AutoButtonColor = false;
  579. Text = "";
  580. BackgroundColor3 = Color3.fromRGB(20, 20, 20);
  581. BorderSizePixel = 0;
  582. ZIndex = 2;
  583. TextStrokeTransparency = library.options.textstroke;
  584. TextStrokeColor3 = library.options.strokecolor;
  585. });
  586. library:Create('Frame', {
  587. Name = 'Line';
  588. BackgroundTransparency = 0;
  589. Position = UDim2.new(0, 0, 0.5, 0);
  590. Size = UDim2.new(1, 0, 0, 1);
  591. BackgroundColor3 = Color3.fromRGB(255, 255, 255);
  592. BorderSizePixel = 0;
  593. });
  594. })
  595. });
  596. Parent = self.container;
  597. });
  598.  
  599. local overlay = check:FindFirstChild(name);
  600.  
  601. local renderSteppedConnection;
  602. local inputBeganConnection;
  603. local inputEndedConnection;
  604. local mouseLeaveConnection;
  605. local mouseDownConnection;
  606. local mouseUpConnection;
  607.  
  608. check:FindFirstChild(name).Container.MouseEnter:connect(function()
  609. local function update()
  610. if renderSteppedConnection then renderSteppedConnection:disconnect() end
  611.  
  612.  
  613. renderSteppedConnection = game:GetService('RunService').RenderStepped:connect(function()
  614. local mouse = game:GetService("UserInputService"):GetMouseLocation()
  615. local percent = (mouse.X - overlay.Container.AbsolutePosition.X) / (overlay.Container.AbsoluteSize.X)
  616. percent = math.clamp(percent, 0, 1)
  617. percent = tonumber(string.format("%.2f", percent))
  618.  
  619. overlay.Container.Button.Position = UDim2.new(math.clamp(percent, 0, 0.99), 0, 0, 1)
  620.  
  621. local num = min + (max - min) * percent
  622. local value = (precise and num or math.floor(num))
  623.  
  624. overlay.Container.ValueLabel.Text = value;
  625. callback(tonumber(value))
  626. location[flag] = tonumber(value)
  627. end)
  628. end
  629.  
  630. local function disconnect()
  631. if renderSteppedConnection then renderSteppedConnection:disconnect() end
  632. if inputBeganConnection then inputBeganConnection:disconnect() end
  633. if inputEndedConnection then inputEndedConnection:disconnect() end
  634. if mouseLeaveConnection then mouseLeaveConnection:disconnect() end
  635. if mouseUpConnection then mouseUpConnection:disconnect() end
  636. end
  637.  
  638. inputBeganConnection = check:FindFirstChild(name).Container.InputBegan:connect(function(input)
  639. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  640. update()
  641. end
  642. end)
  643.  
  644. inputEndedConnection = check:FindFirstChild(name).Container.InputEnded:connect(function(input)
  645. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  646. disconnect()
  647. end
  648. end)
  649.  
  650. mouseDownConnection = check:FindFirstChild(name).Container.Button.MouseButton1Down:connect(update)
  651. mouseUpConnection = game:GetService("UserInputService").InputEnded:connect(function(a, b)
  652. if a.UserInputType == Enum.UserInputType.MouseButton1 and (mouseDownConnection.Connected) then
  653. disconnect()
  654. end
  655. end)
  656. end)
  657.  
  658. if default ~= min then
  659. local percent = 1 - ((max - default) / (max - min))
  660. local number = default
  661.  
  662. number = tonumber(string.format("%.2f", number))
  663. if (not precise) then
  664. number = math.floor(number)
  665. end
  666.  
  667. overlay.Container.Button.Position = UDim2.new(math.clamp(percent, 0, 0.99), 0, 0, 1)
  668. overlay.Container.ValueLabel.Text = number
  669. end
  670.  
  671. self:Resize();
  672. return {
  673. Set = function(self, value)
  674. local percent = 1 - ((max - value) / (max - min))
  675. local number = value
  676.  
  677. number = tonumber(string.format("%.2f", number))
  678. if (not precise) then
  679. number = math.floor(number)
  680. end
  681.  
  682. overlay.Container.Button.Position = UDim2.new(math.clamp(percent, 0, 0.99), 0, 0, 1)
  683. overlay.Container.ValueLabel.Text = number
  684. location[flag] = number
  685. callback(number)
  686. end
  687. }
  688. end
  689.  
  690. function types:SearchBox(text, options, callback)
  691. local list = options.list or {};
  692. local flag = options.flag or "";
  693. local location = options.location or self.flags;
  694. local callback = callback or function() end;
  695.  
  696. local busy = false;
  697. local box = library:Create('Frame', {
  698. BackgroundTransparency = 1;
  699. Size = UDim2.new(1, 0, 0, 25);
  700. LayoutOrder = self:GetOrder();
  701. library:Create('TextBox', {
  702. Text = "";
  703. PlaceholderText = text;
  704. PlaceholderColor3 = Color3.fromRGB(60, 60, 60);
  705. Font = library.options.font;
  706. TextSize = library.options.fontsize;
  707. Name = 'Box';
  708. Size = UDim2.new(1, -10, 0, 20);
  709. Position = UDim2.new(0, 5, 0, 4);
  710. TextColor3 = library.options.textcolor;
  711. BackgroundColor3 = library.options.dropcolor;
  712. BorderColor3 = library.options.bordercolor;
  713. TextStrokeTransparency = library.options.textstroke;
  714. TextStrokeColor3 = library.options.strokecolor;
  715. library:Create('ScrollingFrame', {
  716. Position = UDim2.new(0, 0, 1, 1);
  717. Name = 'Container';
  718. BackgroundColor3 = library.options.btncolor;
  719. ScrollBarThickness = 0;
  720. BorderSizePixel = 0;
  721. BorderColor3 = library.options.bordercolor;
  722. Size = UDim2.new(1, 0, 0, 0);
  723. library:Create('UIListLayout', {
  724. Name = 'ListLayout';
  725. SortOrder = Enum.SortOrder.LayoutOrder;
  726. });
  727. ZIndex = 2;
  728. });
  729. });
  730. Parent = self.container;
  731. })
  732.  
  733. local function rebuild(text)
  734. box:FindFirstChild('Box').Container.ScrollBarThickness = 0
  735. for i, child in next, box:FindFirstChild('Box').Container:GetChildren() do
  736. if (not child:IsA('UIListLayout')) then
  737. child:Destroy();
  738. end
  739. end
  740.  
  741. if #text > 0 then
  742. for i, v in next, list do
  743. if string.sub(string.lower(v), 1, string.len(text)) == string.lower(text) then
  744. local button = library:Create('TextButton', {
  745. Text = v;
  746. Font = library.options.font;
  747. TextSize = library.options.fontsize;
  748. TextColor3 = library.options.textcolor;
  749. BorderColor3 = library.options.bordercolor;
  750. TextStrokeTransparency = library.options.textstroke;
  751. TextStrokeColor3 = library.options.strokecolor;
  752. Parent = box:FindFirstChild('Box').Container;
  753. Size = UDim2.new(1, 0, 0, 20);
  754. LayoutOrder = i;
  755. BackgroundColor3 = library.options.btncolor;
  756. ZIndex = 2;
  757. })
  758.  
  759. button.MouseButton1Click:connect(function()
  760. busy = true;
  761. box:FindFirstChild('Box').Text = button.Text;
  762. wait();
  763. busy = false;
  764.  
  765. location[flag] = button.Text;
  766. callback(location[flag])
  767.  
  768. box:FindFirstChild('Box').Container.ScrollBarThickness = 0
  769. for i, child in next, box:FindFirstChild('Box').Container:GetChildren() do
  770. if (not child:IsA('UIListLayout')) then
  771. child:Destroy();
  772. end
  773. end
  774. box:FindFirstChild('Box').Container:TweenSize(UDim2.new(1, 0, 0, 0), 'Out', 'Quad', 0.25, true)
  775. end)
  776. end
  777. end
  778. end
  779.  
  780. local c = box:FindFirstChild('Box').Container:GetChildren()
  781. local ry = (20 * (#c)) - 20
  782.  
  783. local y = math.clamp((20 * (#c)) - 20, 0, 100)
  784. if ry > 100 then
  785. box:FindFirstChild('Box').Container.ScrollBarThickness = 5;
  786. end
  787.  
  788. box:FindFirstChild('Box').Container:TweenSize(UDim2.new(1, 0, 0, y), 'Out', 'Quad', 0.25, true)
  789. box:FindFirstChild('Box').Container.CanvasSize = UDim2.new(1, 0, 0, (20 * (#c)) - 20)
  790. end
  791.  
  792. box:FindFirstChild('Box'):GetPropertyChangedSignal('Text'):connect(function()
  793. if (not busy) then
  794. rebuild(box:FindFirstChild('Box').Text)
  795. end
  796. end);
  797.  
  798. local function reload(new_list)
  799. list = new_list;
  800. rebuild("")
  801. end
  802. self:Resize();
  803. return reload, box:FindFirstChild('Box');
  804. end
  805.  
  806. function types:Dropdown(name, options, callback)
  807. local location = options.location or self.flags;
  808. local flag = options.flag or "";
  809. local callback = callback or function() end;
  810. local list = options.list or {};
  811.  
  812. location[flag] = list[1]
  813. local check = library:Create('Frame', {
  814. BackgroundTransparency = 1;
  815. Size = UDim2.new(1, 0, 0, 25);
  816. BackgroundColor3 = Color3.fromRGB(25, 25, 25);
  817. BorderSizePixel = 0;
  818. LayoutOrder = self:GetOrder();
  819. library:Create('Frame', {
  820. Name = 'dropdown_lbl';
  821. BackgroundTransparency = 0;
  822. BackgroundColor3 = library.options.dropcolor;
  823. Position = UDim2.new(0, 5, 0, 4);
  824. BorderColor3 = library.options.bordercolor;
  825. Size = UDim2.new(1, -10, 0, 20);
  826. library:Create('TextLabel', {
  827. Name = 'Selection';
  828. Size = UDim2.new(1, 0, 1, 0);
  829. Text = list[1];
  830. TextColor3 = library.options.textcolor;
  831. BackgroundTransparency = 1;
  832. Font = library.options.font;
  833. TextSize = library.options.fontsize;
  834. TextStrokeTransparency = library.options.textstroke;
  835. TextStrokeColor3 = library.options.strokecolor;
  836. });
  837. library:Create("TextButton", {
  838. Name = 'drop';
  839. BackgroundTransparency = 1;
  840. Size = UDim2.new(0, 20, 1, 0);
  841. Position = UDim2.new(1, -25, 0, 0);
  842. Text = 'v';
  843. TextColor3 = library.options.textcolor;
  844. Font = library.options.font;
  845. TextSize = library.options.fontsize;
  846. TextStrokeTransparency = library.options.textstroke;
  847. TextStrokeColor3 = library.options.strokecolor;
  848. })
  849. });
  850. Parent = self.container;
  851. });
  852.  
  853. local button = check:FindFirstChild('dropdown_lbl').drop;
  854. local input;
  855.  
  856. button.MouseButton1Click:connect(function()
  857. if (input and input.Connected) then
  858. return
  859. end
  860.  
  861. check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').TextColor3 = Color3.fromRGB(60, 60, 60);
  862. check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').Text = name;
  863. local c = 0;
  864. for i, v in next, list do
  865. c = c + 20;
  866. end
  867.  
  868. local size = UDim2.new(1, 0, 0, c)
  869.  
  870. local clampedSize;
  871. local scrollSize = 0;
  872. if size.Y.Offset > 100 then
  873. clampedSize = UDim2.new(1, 0, 0, 100)
  874. scrollSize = 5;
  875. end
  876.  
  877. local goSize = (clampedSize ~= nil and clampedSize) or size;
  878. local container = library:Create('ScrollingFrame', {
  879. TopImage = 'rbxasset://textures/ui/Scroll/scroll-middle.png';
  880. BottomImage = 'rbxasset://textures/ui/Scroll/scroll-middle.png';
  881. Name = 'DropContainer';
  882. Parent = check:FindFirstChild('dropdown_lbl');
  883. Size = UDim2.new(1, 0, 0, 0);
  884. BackgroundColor3 = library.options.bgcolor;
  885. BorderColor3 = library.options.bordercolor;
  886. Position = UDim2.new(0, 0, 1, 0);
  887. ScrollBarThickness = scrollSize;
  888. CanvasSize = UDim2.new(0, 0, 0, size.Y.Offset);
  889. ZIndex = 5;
  890. ClipsDescendants = true;
  891. library:Create('UIListLayout', {
  892. Name = 'List';
  893. SortOrder = Enum.SortOrder.LayoutOrder
  894. })
  895. })
  896.  
  897. for i, v in next, list do
  898. local btn = library:Create('TextButton', {
  899. Size = UDim2.new(1, 0, 0, 20);
  900. BackgroundColor3 = library.options.btncolor;
  901. BorderColor3 = library.options.bordercolor;
  902. Text = v;
  903. Font = library.options.font;
  904. TextSize = library.options.fontsize;
  905. LayoutOrder = i;
  906. Parent = container;
  907. ZIndex = 5;
  908. TextColor3 = library.options.textcolor;
  909. TextStrokeTransparency = library.options.textstroke;
  910. TextStrokeColor3 = library.options.strokecolor;
  911. })
  912.  
  913. btn.MouseButton1Click:connect(function()
  914. check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').TextColor3 = library.options.textcolor
  915. check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').Text = btn.Text;
  916.  
  917. location[flag] = tostring(btn.Text);
  918. callback(location[flag])
  919.  
  920. game:GetService('Debris'):AddItem(container, 0)
  921. input:disconnect();
  922. end)
  923. end
  924.  
  925. container:TweenSize(goSize, 'Out', 'Quad', 0.15, true)
  926.  
  927. local function isInGui(frame)
  928. local mloc = game:GetService('UserInputService'):GetMouseLocation();
  929. local mouse = Vector2.new(mloc.X, mloc.Y - 36);
  930.  
  931. local x1, x2 = frame.AbsolutePosition.X, frame.AbsolutePosition.X + frame.AbsoluteSize.X;
  932. local y1, y2 = frame.AbsolutePosition.Y, frame.AbsolutePosition.Y + frame.AbsoluteSize.Y;
  933.  
  934. return (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2)
  935. end
  936.  
  937. input = game:GetService('UserInputService').InputBegan:connect(function(a)
  938. if a.UserInputType == Enum.UserInputType.MouseButton1 and (not isInGui(container)) then
  939. check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').TextColor3 = library.options.textcolor
  940. check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').Text = location[flag];
  941.  
  942. container:TweenSize(UDim2.new(1, 0, 0, 0), 'In', 'Quad', 0.15, true)
  943. wait(0.15)
  944.  
  945. game:GetService('Debris'):AddItem(container, 0)
  946. input:disconnect();
  947. end
  948. end)
  949. end)
  950.  
  951. self:Resize();
  952. local function reload(self, array)
  953. options = array;
  954. location[flag] = array[1];
  955. pcall(function()
  956. input:disconnect()
  957. end)
  958. check:WaitForChild('dropdown_lbl').Selection.Text = location[flag]
  959. check:FindFirstChild('dropdown_lbl'):WaitForChild('Selection').TextColor3 = library.options.textcolor
  960. game:GetService('Debris'):AddItem(container, 0)
  961. end
  962.  
  963. return {
  964. Refresh = reload;
  965. }
  966. end
  967. end
  968.  
  969. function library:Create(class, data)
  970. local obj = Instance.new(class);
  971. for i, v in next, data do
  972. if i ~= 'Parent' then
  973.  
  974. if typeof(v) == "Instance" then
  975. v.Parent = obj;
  976. else
  977. obj[i] = v
  978. end
  979. end
  980. end
  981.  
  982. obj.Parent = data.Parent;
  983. return obj
  984. end
  985.  
  986. function library:CreateWindow(name, options)
  987. if (not library.container) then
  988. library.container = self:Create("ScreenGui", {
  989. self:Create('Frame', {
  990. Name = 'Container';
  991. Size = UDim2.new(1, -30, 1, 0);
  992. Position = UDim2.new(0, 20, 0, 20);
  993. BackgroundTransparency = 1;
  994. Active = false;
  995. });
  996. Parent = game:GetService("CoreGui");
  997. }):FindFirstChild('Container');
  998. end
  999.  
  1000. if (not library.options) then
  1001. library.options = setmetatable(options or {}, {__index = defaults})
  1002. end
  1003.  
  1004. local window = types.window(name, library.options);
  1005. dragger.new(window.object);
  1006. return window
  1007. end
  1008.  
  1009. default = {
  1010. topcolor = Color3.fromRGB(30, 30, 30);
  1011. titlecolor = Color3.fromRGB(255, 255, 255);
  1012.  
  1013. underlinecolor = Color3.fromRGB(0, 255, 140);
  1014. bgcolor = Color3.fromRGB(35, 35, 35);
  1015. boxcolor = Color3.fromRGB(35, 35, 35);
  1016. btncolor = Color3.fromRGB(25, 25, 25);
  1017. dropcolor = Color3.fromRGB(25, 25, 25);
  1018. sectncolor = Color3.fromRGB(25, 25, 25);
  1019. bordercolor = Color3.fromRGB(80, 80, 80);
  1020.  
  1021. font = Enum.Font.SourceSans;
  1022. titlefont = Enum.Font.Code;
  1023.  
  1024. fontsize = 17;
  1025. titlesize = 18;
  1026.  
  1027. textstroke = 1;
  1028. titlestroke = 1;
  1029.  
  1030. strokecolor = Color3.fromRGB(0, 0, 0);
  1031.  
  1032. textcolor = Color3.fromRGB(255, 255, 255);
  1033. titletextcolor = Color3.fromRGB(255, 255, 255);
  1034.  
  1035. placeholdercolor = Color3.fromRGB(255, 255, 255);
  1036. titlestrokecolor = Color3.fromRGB(0, 0, 0);
  1037. }
  1038.  
  1039. library.options = setmetatable({}, {__index = default})
  1040.  
  1041. spawn(function()
  1042. while true do
  1043. for i=0, 1, 1 / 300 do
  1044. for _, obj in next, library.rainbowtable do
  1045. obj.BackgroundColor3 = Color3.fromHSV(i, 1, 1);
  1046. end
  1047. wait()
  1048. end;
  1049. end
  1050. end)
  1051.  
  1052. local function isreallypressed(bind, inp)
  1053. local key = bind
  1054. if typeof(key) == "Instance" then
  1055. if key.UserInputType == Enum.UserInputType.Keyboard and inp.KeyCode == key.KeyCode then
  1056. return true;
  1057. elseif tostring(key.UserInputType):find('MouseButton') and inp.UserInputType == key.UserInputType then
  1058. return true
  1059. end
  1060. end
  1061. if tostring(key):find'MouseButton1' then
  1062. return key == inp.UserInputType
  1063. else
  1064. return key == inp.KeyCode
  1065. end
  1066. end
  1067.  
  1068. game:GetService("UserInputService").InputBegan:connect(function(input)
  1069. if (not library.binding) then
  1070. for idx, binds in next, library.binds do
  1071. local real_binding = binds.location[idx];
  1072. if real_binding and isreallypressed(real_binding, input) then
  1073. binds.callback()
  1074. end
  1075. end
  1076. end
  1077. end)
  1078. end
  1079.  
  1080. return library
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement