trollhackerdude

skid

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