AOM-GU-PRO

library2

Feb 4th, 2020
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.23 KB | None | 0 0
  1. local library = {
  2. windowcount = 0;
  3. }
  4.  
  5. local dragger = {};
  6. local resizer = {};
  7.  
  8. do
  9. local mouse = game:GetService("Players").LocalPlayer:GetMouse();
  10. local inputService = game:GetService('UserInputService');
  11. local heartbeat = game:GetService("RunService").Heartbeat;
  12. -- // credits to Ririchi / Inori for this cute drag function :)
  13. function dragger.new(frame)
  14. local s, event = pcall(function()
  15. return frame.MouseEnter
  16. end)
  17.  
  18. if s then
  19. frame.Active = true;
  20.  
  21. event:connect(function()
  22. local input = frame.InputBegan:connect(function(key)
  23. if key.UserInputType == Enum.UserInputType.MouseButton1 then
  24. local objectPosition = Vector2.new(mouse.X - frame.AbsolutePosition.X, mouse.Y - frame.AbsolutePosition.Y);
  25. while heartbeat:wait() and inputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
  26. 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', 'Quad', 0.1, true);
  27. end
  28. end
  29. end)
  30.  
  31. local leave;
  32. leave = frame.MouseLeave:connect(function()
  33. input:disconnect();
  34. leave:disconnect();
  35. end)
  36. end)
  37. end
  38. end
  39.  
  40. function resizer.new(p, s)
  41. p:GetPropertyChangedSignal('AbsoluteSize'):connect(function()
  42. s.Size = UDim2.new(s.Size.X.Scale, s.Size.X.Offset, s.Size.Y.Scale, p.AbsoluteSize.Y);
  43. end)
  44. end
  45. end
  46.  
  47.  
  48. local defaults = {
  49. txtcolor = Color3.fromRGB(255, 255, 255),
  50. underline = Color3.fromRGB(255, 0, 255),
  51. barcolor = Color3.fromRGB(40, 40, 40),
  52. bgcolor = Color3.fromRGB(30, 30, 30),
  53. }
  54.  
  55. function library:Create(class, props)
  56. local object = Instance.new(class);
  57.  
  58. for i, prop in next, props do
  59. if i ~= "Parent" then
  60. object[i] = prop;
  61. end
  62. end
  63.  
  64. object.Parent = props.Parent;
  65. return object;
  66. end
  67.  
  68. function library:CreateWindow(options,setud)
  69. assert(options.text, "no name");
  70. local window = {
  71. count = 0;
  72. toggles = {},
  73. closed = false;
  74. }
  75.  
  76. local options = options or {};
  77. setmetatable(options, {__index = defaults})
  78.  
  79. self.windowcount = self.windowcount + 1;
  80.  
  81. library.gui = library.gui or self:Create("ScreenGui", {Name = "ZeroHack", Parent = game:GetService("CoreGui")})
  82. window.frame = self:Create("Frame", {
  83. Name = options.text;
  84. Parent = self.gui,
  85. Active = true,
  86. BackgroundTransparency = 0,
  87. Size = setud,
  88. Position = UDim2.new(0, (15 + ((200 * self.windowcount) - 200)), 0, 15),
  89. BackgroundColor3 = options.barcolor,
  90. BorderSizePixel = 0;
  91. })
  92.  
  93. window.background = self:Create('Frame', {
  94. Name = 'Background';
  95. Parent = window.frame,
  96. BorderSizePixel = 0;
  97. BackgroundColor3 = options.bgcolor,
  98. Position = UDim2.new(0, 0, 1, 0),
  99. Size = UDim2.new(1, 0, 0, 25),
  100. ClipsDescendants = true;
  101. })
  102.  
  103. window.container = self:Create('Frame', {
  104. Name = 'Container';
  105. Parent = window.frame,
  106. BorderSizePixel = 0;
  107. BackgroundColor3 = options.bgcolor,
  108. Position = UDim2.new(0, 0, 1, 0),
  109. Size = UDim2.new(1, 0, 0, 25),
  110. ClipsDescendants = true;
  111. })
  112.  
  113. window.organizer = self:Create('UIListLayout', {
  114. Name = 'Sorter';
  115. --Padding = UDim.new(0, 0);
  116. SortOrder = Enum.SortOrder.LayoutOrder;
  117. Parent = window.container;
  118. })
  119.  
  120. window.padder = self:Create('UIPadding', {
  121. Name = 'Padding';
  122. PaddingLeft = UDim.new(0, 10);
  123. PaddingTop = UDim.new(0, 5);
  124. Parent = window.container;
  125. })
  126.  
  127. self:Create("Frame", {
  128. Name = 'Underline';
  129. Size = UDim2.new(1, 0, 0, 1),
  130. Position = UDim2.new(0, 0, 1, -1),
  131. BorderSizePixel = 0;
  132. BackgroundColor3 = options.underline;
  133. Parent = window.frame
  134. })
  135.  
  136. local togglebutton = self:Create("TextButton", {
  137. Name = 'Toggle';
  138. ZIndex = 2,
  139. BackgroundTransparency = 1;
  140. Position = UDim2.new(1, -25, 0, 0),
  141. Size = UDim2.new(0, 25, 1, 0),
  142. Text = "-",
  143. TextSize = 17,
  144. TextColor3 = options.txtcolor,
  145. Font = Enum.Font.SourceSans;
  146. Parent = window.frame,
  147. });
  148.  
  149. togglebutton.MouseButton1Click:connect(function()
  150. window.closed = not window.closed
  151. togglebutton.Text = (window.closed and "+" or "-")
  152. if window.closed then
  153. window:Resize(true, UDim2.new(1, 0, 0, 0))
  154. else
  155. window:Resize(true)
  156. end
  157. end)
  158.  
  159. self:Create("TextLabel", {
  160. Size = UDim2.new(1, 0, 1, 0),
  161. BackgroundTransparency = 1;
  162. BorderSizePixel = 0;
  163. TextColor3 = options.txtcolor,
  164. TextColor3 = (options.bartextcolor or Color3.fromRGB(255, 255, 255));
  165. TextSize = 17,
  166. Font = Enum.Font.SourceSansSemibold;
  167. Text = options.text or "window",
  168. Name = "Window",
  169. Parent = window.frame,
  170. })
  171.  
  172. do
  173. dragger.new(window.frame)
  174. resizer.new(window.background, window.container);
  175. end
  176.  
  177. local function getSize()
  178. local ySize = 0;
  179. for i, object in next, window.container:GetChildren() do
  180. if (not object:IsA('UIListLayout')) and (not object:IsA('UIPadding')) then
  181. ySize = ySize + object.AbsoluteSize.Y
  182. end
  183. end
  184. return UDim2.new(1, 0, 0, ySize + 10)
  185. end
  186.  
  187. function window:Resize(tween, change)
  188. local size = change or getSize()
  189. self.container.ClipsDescendants = true;
  190.  
  191. if tween then
  192. self.background:TweenSize(size, "Out", "Sine", 0.5, true)
  193. else
  194. self.background.Size = size
  195. end
  196. end
  197.  
  198. function window:AddToggle(text, callback)
  199. self.count = self.count + 1
  200.  
  201. callback = callback or function() end
  202. local label = library:Create("TextLabel", {
  203. Text = text,
  204. Size = UDim2.new(1, -10, 0, 20);
  205. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  206. BackgroundTransparency = 1;
  207. TextColor3 = Color3.fromRGB(255, 255, 255);
  208. TextXAlignment = Enum.TextXAlignment.Left;
  209. LayoutOrder = self.Count;
  210. TextSize = 16,
  211. Font = Enum.Font.SourceSans,
  212. Parent = self.container;
  213. })
  214.  
  215. local button = library:Create("TextButton", {
  216. Text = "OFF",
  217. TextColor3 = Color3.fromRGB(255, 25, 25),
  218. BackgroundTransparency = 1;
  219. Position = UDim2.new(1, -25, 0, 0),
  220. Size = UDim2.new(0, 25, 1, 0),
  221. TextSize = 17,
  222. Font = Enum.Font.SourceSansSemibold,
  223. Parent = label;
  224. })
  225.  
  226. button.MouseButton1Click:connect(function()
  227. self.toggles[text] = (not self.toggles[text])
  228. button.TextColor3 = (self.toggles[text] and Color3.fromRGB(0, 255, 140) or Color3.fromRGB(255, 25, 25))
  229. button.Text =(self.toggles[text] and "ON" or "OFF")
  230.  
  231. callback(self.toggles[text])
  232. end)
  233.  
  234. self:Resize()
  235. return button
  236. end
  237.  
  238. function window:AddBox(text, callback)
  239. self.count = self.count + 1
  240. callback = callback or function() end
  241.  
  242. local box = library:Create("TextBox", {
  243. PlaceholderText = text,
  244. Size = UDim2.new(1, -10, 0, 20);
  245. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  246. BackgroundTransparency = 0.75;
  247. BackgroundColor3 = options.boxcolor,
  248. TextColor3 = Color3.fromRGB(255, 255, 255);
  249. TextXAlignment = Enum.TextXAlignment.Center;
  250. TextSize = 16,
  251. Text = "",
  252. Font = Enum.Font.SourceSans,
  253. LayoutOrder = self.Count;
  254. BorderSizePixel = 0;
  255. Parent = self.container;
  256. })
  257.  
  258. box.FocusLost:connect(function(...)
  259. callback(box, ...)
  260. end)
  261.  
  262. self:Resize()
  263. return box
  264. end
  265.  
  266. function window:AddButton(text, callback)
  267. self.count = self.count + 1
  268.  
  269. callback = callback or function() end
  270. local button = library:Create("TextButton", {
  271. Text = text,
  272. Size = UDim2.new(1, -10, 0, 20);
  273. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  274. BackgroundTransparency = 1;
  275. TextColor3 = Color3.fromRGB(255, 255, 255);
  276. TextXAlignment = Enum.TextXAlignment.Left;
  277. TextSize = 16,
  278. Font = Enum.Font.SourceSans,
  279. LayoutOrder = self.Count;
  280. Parent = self.container;
  281. })
  282.  
  283. button.MouseButton1Click:connect(callback)
  284. self:Resize()
  285. return button
  286. end
  287.  
  288. function window:AddButton2(text, C3, callback)
  289. self.count = self.count + 1
  290.  
  291. callback = callback or function() end
  292. local button = library:Create("TextButton", {
  293. Text = text,
  294. Size = UDim2.new(1, -10, 0, 20);
  295. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  296. BackgroundTransparency = 0.95;
  297. BackgroundColor3 = C3,
  298. TextColor3 = C3;
  299. TextSize = 16,
  300. Font = Enum.Font.SourceSans,
  301. LayoutOrder = self.Count;
  302. Parent = self.container;
  303. })
  304. button.MouseButton1Click:connect(callback)
  305. self:Resize()
  306. return button
  307. end
  308.  
  309. function window:AddLabel(text)
  310. self.count = self.count + 1;
  311.  
  312. local tSize = game:GetService('TextService'):GetTextSize(text, 16, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  313.  
  314. local button = library:Create("TextLabel", {
  315. Text = text,
  316. Size = UDim2.new(1, -10, 0, tSize.Y + 5);
  317. TextScaled = false;
  318. BackgroundTransparency = 1;
  319. TextColor3 = Color3.fromRGB(255, 255, 255);
  320. TextXAlignment = Enum.TextXAlignment.Left;
  321. TextSize = 16,
  322. Font = Enum.Font.SourceSans,
  323. LayoutOrder = self.Count;
  324. Parent = self.container;
  325. })
  326.  
  327. self:Resize()
  328. return button
  329. end
  330.  
  331. function window:AddLabel2(text)
  332. self.count = self.count + 1;
  333.  
  334. local tSize = game:GetService('TextService'):GetTextSize(text, 16, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  335.  
  336. local button = library:Create("TextLabel", {
  337. Text = text,
  338. Size = UDim2.new(1, -10, 0, tSize.Y + 5);
  339. TextScaled = false;
  340. BackgroundTransparency = 0.75;
  341. BackgroundColor3 = options.boxcolor,
  342. TextColor3 = Color3.fromRGB(255, 255, 255);
  343. --TextXAlignment = Enum.TextXAlignment.Left;
  344. TextSize = 16,
  345. Font = Enum.Font.SourceSans,
  346. LayoutOrder = self.Count;
  347. Parent = self.container;
  348. })
  349.  
  350. self:Resize()
  351. return button
  352. end
  353.  
  354. function window:AddLabel3(text)
  355. self.count = self.count + 1;
  356.  
  357. local tSize = game:GetService('TextService'):GetTextSize(text, 16, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  358.  
  359. local button = library:Create("TextLabel", {
  360. Text = text,
  361. Size = UDim2.new(1, -10, 0, tSize.Y + 5);
  362. TextScaled = true;
  363. BackgroundTransparency = 0.75;
  364. BackgroundColor3 = options.boxcolor,
  365. TextColor3 = Color3.fromRGB(255, 255, 255);
  366. TextSize = 16,
  367. Font = Enum.Font.SourceSans,
  368. LayoutOrder = self.Count;
  369. Parent = self.container;
  370. })
  371.  
  372. self:Resize()
  373. return button
  374. end
  375.  
  376. function window:AddDropdown(options, callback)
  377. self.count = self.count + 1
  378. local default = options[1] or "";
  379.  
  380. callback = callback or function() end
  381. local dropdown = library:Create("TextLabel", {
  382. Size = UDim2.new(1, -10, 0, 20);
  383. BackgroundTransparency = 0.75;
  384. BackgroundColor3 = options.boxcolor,
  385. TextColor3 = Color3.fromRGB(255, 255, 255);
  386. TextXAlignment = Enum.TextXAlignment.Center;
  387. TextSize = 16,
  388. Text = default,
  389. Font = Enum.Font.SourceSans,
  390. BorderSizePixel = 0;
  391. LayoutOrder = self.Count;
  392. Parent = self.container;
  393. })
  394.  
  395. local button = library:Create("ImageButton",{
  396. BackgroundTransparency = 1;
  397. Image = 'rbxassetid://3234893186';
  398. Size = UDim2.new(0, 18, 1, 0);
  399. Position = UDim2.new(1, -20, 0, 0);
  400. Parent = dropdown;
  401. })
  402.  
  403. local frame;
  404.  
  405. local function isInGui(frame)
  406. local mloc = game:GetService('UserInputService'):GetMouseLocation();
  407. local mouse = Vector2.new(mloc.X, mloc.Y - 36);
  408.  
  409. local x1, x2 = frame.AbsolutePosition.X, frame.AbsolutePosition.X + frame.AbsoluteSize.X;
  410. local y1, y2 = frame.AbsolutePosition.Y, frame.AbsolutePosition.Y + frame.AbsoluteSize.Y;
  411.  
  412. return (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2)
  413. end
  414.  
  415. local function count(t)
  416. local c = 0;
  417. for i, v in next, t do
  418. c = c + 1
  419. end
  420. return c;
  421. end
  422.  
  423. button.MouseButton1Click:connect(function()
  424. if count(options) == 0 then
  425. return
  426. end
  427.  
  428. if frame then
  429. frame:Destroy();
  430. frame = nil;
  431. end
  432.  
  433. self.container.ClipsDescendants = false;
  434.  
  435. frame = library:Create('Frame', {
  436. Position = UDim2.new(0, 0, 1, 0);
  437. BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  438. Size = UDim2.new(0, dropdown.AbsoluteSize.X, 0, (count(options) * 21));
  439. BorderSizePixel = 0;
  440. Parent = dropdown;
  441. ClipsDescendants = true;
  442. ZIndex = 2;
  443. })
  444.  
  445. library:Create('UIListLayout', {
  446. Name = 'Layout';
  447. Parent = frame;
  448. })
  449.  
  450. for i, option in next, options do
  451. local selection = library:Create('TextButton', {
  452. Text = option;
  453. BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  454. TextColor3 = Color3.fromRGB(255, 255, 255);
  455. BorderSizePixel = 0;
  456. TextSize = 16;
  457. Font = Enum.Font.SourceSans;
  458. Size = UDim2.new(1, 0, 0, 21);
  459. Parent = frame;
  460. ZIndex = 2;
  461. })
  462.  
  463. selection.MouseButton1Click:connect(function()
  464. dropdown.Text = option;
  465. callback(option)
  466. frame.Size = UDim2.new(1, 0, 0, 0);
  467. game:GetService('Debris'):AddItem(frame, 0.1)
  468. end)
  469. end
  470. end);
  471.  
  472. game:GetService('UserInputService').InputBegan:connect(function(m)
  473. if m.UserInputType == Enum.UserInputType.MouseButton1 then
  474. if frame and (not isInGui(frame)) then
  475. game:GetService('Debris'):AddItem(frame);
  476. end
  477. end
  478. end)
  479.  
  480. callback(default);
  481. self:Resize()
  482. return {
  483. Refresh = function(self, array)
  484. game:GetService('Debris'):AddItem(frame);
  485. options = array
  486. dropdown.Text = options[1];
  487. end
  488. }
  489. end;
  490.  
  491.  
  492. return window
  493. end
  494.  
  495. return library
Add Comment
Please, Sign In to add comment