Advertisement
dkg_yt

Edited ui LIB.lua

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