Advertisement
asgargg

Untitled

Jun 28th, 2019
3,259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.57 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(0, 255, 140),
  51. barcolor = Color3.fromRGB(40, 40, 40),
  52. bgcolor = Color3.fromRGB(30, 30, 30),
  53. name = "BRUHE"
  54. }
  55.  
  56. defaults.Name = game:HttpGet("https://www.passwordrandom.com/query?command=password&scheme=rrrrrrrrr")
  57.  
  58. function library:Create(class, props)
  59. local object = Instance.new(class);
  60.  
  61. for i, prop in next, props do
  62. if i ~= "Parent" then
  63. object[i] = prop;
  64. end
  65. end
  66.  
  67. object.Parent = props.Parent;
  68. return object;
  69. end
  70.  
  71. function library:CreateWindow(options)
  72. assert(options.text, "no name");
  73. local window = {
  74. count = 0;
  75. toggles = {},
  76. closed = false;
  77. }
  78.  
  79. local options = options or {};
  80. setmetatable(options, {__index = defaults})
  81.  
  82. self.windowcount = self.windowcount + 1;
  83.  
  84. library.gui = library.gui or self:Create("ScreenGui", {Name = defaults.Name, Parent = game:GetService("CoreGui")})
  85. window.frame = self:Create("Frame", {
  86. Name = defaults.text;
  87. Parent = self.gui,
  88. Active = true,
  89. BackgroundTransparency = 0,
  90. Size = UDim2.new(0, 190, 0, 30),
  91. Position = UDim2.new(0, (15 + ((200 * self.windowcount) - 200)), 0, 15),
  92. BackgroundColor3 = options.barcolor,
  93. BorderSizePixel = 0;
  94. })
  95.  
  96. window.background = self:Create('Frame', {
  97. Name = defaults.Name;
  98. Parent = window.frame,
  99. BorderSizePixel = 0;
  100. BackgroundColor3 = options.bgcolor,
  101. Position = UDim2.new(0, 0, 1, 0),
  102. Size = UDim2.new(1, 0, 0, 25),
  103. ClipsDescendants = true;
  104. })
  105.  
  106. window.container = self:Create('Frame', {
  107. Name = defaults.Name;
  108. Parent = window.frame,
  109. BorderSizePixel = 0;
  110. BackgroundColor3 = options.bgcolor,
  111. Position = UDim2.new(0, 0, 1, 0),
  112. Size = UDim2.new(1, 0, 0, 25),
  113. ClipsDescendants = true;
  114. })
  115.  
  116. window.organizer = self:Create('UIListLayout', {
  117. Name = defaults.Name;
  118. --Padding = UDim.new(0, 0);
  119. SortOrder = Enum.SortOrder.LayoutOrder;
  120. Parent = window.container;
  121. })
  122.  
  123. window.padder = self:Create('UIPadding', {
  124. Name = defaults.Name;
  125. PaddingLeft = UDim.new(0, 10);
  126. PaddingTop = UDim.new(0, 5);
  127. Parent = window.container;
  128. })
  129.  
  130. self:Create("Frame", {
  131. Name = defaults.Name;
  132. Size = UDim2.new(1, 0, 0, 1),
  133. Position = UDim2.new(0, 0, 1, -1),
  134. BorderSizePixel = 0;
  135. BackgroundColor3 = options.underline;
  136. Parent = window.frame
  137. })
  138.  
  139. local togglebutton = self:Create("TextButton", {
  140. Name = defaults.Name;
  141. ZIndex = 2,
  142. BackgroundTransparency = 1;
  143. Position = UDim2.new(1, -25, 0, 0),
  144. Size = UDim2.new(0, 25, 1, 0),
  145. Text = "-",
  146. TextSize = 17,
  147. TextColor3 = options.txtcolor,
  148. Font = Enum.Font.SourceSans;
  149. Parent = window.frame,
  150. });
  151.  
  152. togglebutton.MouseButton1Click:connect(function()
  153. window.closed = not window.closed
  154. togglebutton.Text = (window.closed and "+" or "-")
  155. if window.closed then
  156. window:Resize(true, UDim2.new(1, 0, 0, 0))
  157. else
  158. window:Resize(true)
  159. end
  160. end)
  161.  
  162. self:Create("TextLabel", {
  163. Size = UDim2.new(1, 0, 1, 0),
  164. BackgroundTransparency = 1;
  165. BorderSizePixel = 0;
  166. TextColor3 = options.txtcolor,
  167. TextColor3 = (options.bartextcolor or Color3.fromRGB(255, 255, 255));
  168. TextSize = 17,
  169. Font = Enum.Font.SourceSansSemibold;
  170. Text = options.text or "window",
  171. Name = defaults.Name,
  172. Parent = window.frame,
  173. })
  174.  
  175. do
  176. dragger.new(window.frame)
  177. resizer.new(window.background, window.container);
  178. end
  179.  
  180. local function getSize()
  181. local ySize = 0;
  182. for i, object in next, window.container:GetChildren() do
  183. if (not object:IsA('UIListLayout')) and (not object:IsA('UIPadding')) then
  184. ySize = ySize + object.AbsoluteSize.Y
  185. end
  186. end
  187. return UDim2.new(1, 0, 0, ySize + 10)
  188. end
  189.  
  190. function window:Resize(tween, change)
  191. local size = change or getSize()
  192. self.container.ClipsDescendants = true;
  193.  
  194. if tween then
  195. self.background:TweenSize(size, "Out", "Sine", 0.5, true)
  196. else
  197. self.background.Size = size
  198. end
  199. end
  200.  
  201. function window:AddToggle(text, callback)
  202. self.count = self.count + 1
  203.  
  204. callback = callback or function() end
  205. local label = library:Create("TextLabel", {
  206. Text = text,
  207. Size = UDim2.new(1, -10, 0, 20);
  208. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  209. BackgroundTransparency = 1;
  210. TextColor3 = Color3.fromRGB(255, 255, 255);
  211. TextXAlignment = Enum.TextXAlignment.Left;
  212. LayoutOrder = self.Count;
  213. TextSize = 16,
  214. Font = Enum.Font.SourceSans,
  215. Parent = self.container;
  216. })
  217.  
  218. local button = library:Create("TextButton", {
  219. Text = "OFF",
  220. TextColor3 = Color3.fromRGB(255, 25, 25),
  221. BackgroundTransparency = 1;
  222. Position = UDim2.new(1, -25, 0, 0),
  223. Size = UDim2.new(0, 25, 1, 0),
  224. TextSize = 17,
  225. Font = Enum.Font.SourceSansSemibold,
  226. Parent = label;
  227. })
  228.  
  229. button.MouseButton1Click:connect(function()
  230. self.toggles[text] = (not self.toggles[text])
  231. button.TextColor3 = (self.toggles[text] and Color3.fromRGB(0, 255, 140) or Color3.fromRGB(255, 25, 25))
  232. button.Text =(self.toggles[text] and "ON" or "OFF")
  233.  
  234. callback(self.toggles[text])
  235. end)
  236.  
  237. self:Resize()
  238. return button
  239. end
  240.  
  241. function window:AddBox(text, callback)
  242. self.count = self.count + 1
  243. callback = callback or function() end
  244.  
  245. local box = library:Create("TextBox", {
  246. PlaceholderText = text,
  247. Size = UDim2.new(1, -10, 0, 20);
  248. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  249. BackgroundTransparency = 0.75;
  250. BackgroundColor3 = options.boxcolor,
  251. TextColor3 = Color3.fromRGB(255, 255, 255);
  252. TextXAlignment = Enum.TextXAlignment.Center;
  253. TextSize = 16,
  254. Text = "",
  255. Font = Enum.Font.SourceSans,
  256. LayoutOrder = self.Count;
  257. BorderSizePixel = 0;
  258. Parent = self.container;
  259. })
  260.  
  261. box.FocusLost:connect(function(...)
  262. callback(box, ...)
  263. end)
  264.  
  265. self:Resize()
  266. return box
  267. end
  268.  
  269. function window:AddButton(text, callback)
  270. self.count = self.count + 1
  271.  
  272. callback = callback or function() end
  273. local button = library:Create("TextButton", {
  274. Text = text,
  275. Size = UDim2.new(1, -10, 0, 20);
  276. --Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
  277. BackgroundTransparency = 1;
  278. TextColor3 = Color3.fromRGB(255, 255, 255);
  279. TextXAlignment = Enum.TextXAlignment.Left;
  280. TextSize = 16,
  281. Font = Enum.Font.SourceSans,
  282. LayoutOrder = self.Count;
  283. Parent = self.container;
  284. })
  285.  
  286. button.MouseButton1Click:connect(callback)
  287. self:Resize()
  288. return button
  289. end
  290.  
  291. function window:AddLabel(text)
  292. self.count = self.count + 1;
  293.  
  294. local tSize = game:GetService('TextService'):GetTextSize(text, 16, Enum.Font.SourceSans, Vector2.new(math.huge, math.huge))
  295.  
  296. local button = library:Create("TextLabel", {
  297. Text = text,
  298. Size = UDim2.new(1, -10, 0, tSize.Y + 5);
  299. TextScaled = false;
  300. BackgroundTransparency = 1;
  301. TextColor3 = Color3.fromRGB(255, 255, 255);
  302. TextXAlignment = Enum.TextXAlignment.Left;
  303. TextSize = 16,
  304. Font = Enum.Font.SourceSans,
  305. LayoutOrder = self.Count;
  306. Parent = self.container;
  307. })
  308.  
  309. self:Resize()
  310. return button
  311. end
  312.  
  313. function window:AddDropdown(options, callback)
  314. self.count = self.count + 1
  315. local default = options[1] or "";
  316.  
  317. callback = callback or function() end
  318. local dropdown = library:Create("TextLabel", {
  319. Size = UDim2.new(1, -10, 0, 20);
  320. BackgroundTransparency = 0.75;
  321. BackgroundColor3 = options.boxcolor,
  322. TextColor3 = Color3.fromRGB(255, 255, 255);
  323. TextXAlignment = Enum.TextXAlignment.Center;
  324. TextSize = 16,
  325. Text = default,
  326. Font = Enum.Font.SourceSans,
  327. BorderSizePixel = 0;
  328. LayoutOrder = self.Count;
  329. Parent = self.container;
  330. })
  331.  
  332. local button = library:Create("ImageButton",{
  333. BackgroundTransparency = 1;
  334. Image = 'rbxassetid://3234893186';
  335. Size = UDim2.new(0, 18, 1, 0);
  336. Position = UDim2.new(1, -20, 0, 0);
  337. Parent = dropdown;
  338. })
  339.  
  340. local frame;
  341.  
  342. local function isInGui(frame)
  343. local mloc = game:GetService('UserInputService'):GetMouseLocation();
  344. local mouse = Vector2.new(mloc.X, mloc.Y - 36);
  345.  
  346. local x1, x2 = frame.AbsolutePosition.X, frame.AbsolutePosition.X + frame.AbsoluteSize.X;
  347. local y1, y2 = frame.AbsolutePosition.Y, frame.AbsolutePosition.Y + frame.AbsoluteSize.Y;
  348.  
  349. return (mouse.X >= x1 and mouse.X <= x2) and (mouse.Y >= y1 and mouse.Y <= y2)
  350. end
  351.  
  352. local function count(t)
  353. local c = 0;
  354. for i, v in next, t do
  355. c = c + 1
  356. end
  357. return c;
  358. end
  359.  
  360. button.MouseButton1Click:connect(function()
  361. if count(options) == 0 then
  362. return
  363. end
  364.  
  365. if frame then
  366. frame:Destroy();
  367. frame = nil;
  368. end
  369.  
  370. self.container.ClipsDescendants = false;
  371.  
  372. frame = library:Create('Frame', {
  373. Position = UDim2.new(0, 0, 1, 0);
  374. BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  375. Size = UDim2.new(0, dropdown.AbsoluteSize.X, 0, (count(options) * 21));
  376. BorderSizePixel = 0;
  377. Parent = dropdown;
  378. ClipsDescendants = true;
  379. ZIndex = 2;
  380. })
  381.  
  382. library:Create('UIListLayout', {
  383. Name = defaults.Name;
  384. Parent = frame;
  385. })
  386.  
  387. for i, option in next, options do
  388. local selection = library:Create('TextButton', {
  389. Text = option;
  390. BackgroundColor3 = Color3.fromRGB(40, 40, 40);
  391. TextColor3 = Color3.fromRGB(255, 255, 255);
  392. BorderSizePixel = 0;
  393. TextSize = 16;
  394. Font = Enum.Font.SourceSans;
  395. Size = UDim2.new(1, 0, 0, 21);
  396. Parent = frame;
  397. ZIndex = 2;
  398. })
  399.  
  400. selection.MouseButton1Click:connect(function()
  401. dropdown.Text = option;
  402. callback(option)
  403. frame.Size = UDim2.new(1, 0, 0, 0);
  404. game:GetService('Debris'):AddItem(frame, 0.1)
  405. end)
  406. end
  407. end);
  408.  
  409. game:GetService('UserInputService').InputBegan:connect(function(m)
  410. if m.UserInputType == Enum.UserInputType.MouseButton1 then
  411. if frame and (not isInGui(frame)) then
  412. game:GetService('Debris'):AddItem(frame);
  413. end
  414. end
  415. end)
  416.  
  417. callback(default);
  418. self:Resize()
  419. return {
  420. Refresh = function(self, array)
  421. game:GetService('Debris'):AddItem(frame);
  422. options = array
  423. dropdown.Text = options[1];
  424. end
  425. }
  426. end;
  427.  
  428.  
  429. return window
  430. end
  431.  
  432. return library
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement