trollhackerdude

wally hub ui lib

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