tazerzx

UI Lib

May 18th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.22 KB | None | 0 0
  1.  
  2. local function randomName()
  3. local data = ""
  4. for i=0,20,1 do
  5. data = data .. tostring(string.char(math.ceil(math.random() * 254)))
  6. end
  7. return data
  8. end
  9.  
  10. local ui = Instance.new("ScreenGui")
  11. ui.Name = randomName()
  12. ui.Parent = game:GetService("CoreGui")
  13.  
  14. local library = {}
  15.  
  16. local TweenService = game:GetService("TweenService")
  17. local uis = game:GetService("UserInputService")
  18. local tabcount = 0
  19. local rainbow = 0
  20. _G.breatherate = 0.005
  21. local color
  22. local rainbows = {}
  23. local buttoncount = {}
  24.  
  25. local function draggable(obj)
  26. local globals = {}
  27. globals.dragging=nil
  28. globals.uiorigin=nil
  29. globals.morigin=nil
  30. obj.InputBegan:Connect(function(input)
  31. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  32. globals.dragging = true
  33. globals.uiorigin = obj.Position
  34. globals.morigin = input.Position
  35. input.Changed:Connect(function()
  36. if input.UserInputState == Enum.UserInputState.End then
  37. globals.dragging = false
  38. end
  39. end)
  40. end
  41. end)
  42. uis.InputChanged:Connect(function(input)
  43. if input.UserInputType == Enum.UserInputType.MouseMovement and globals.dragging then
  44. local change = input.Position - globals.morigin
  45. obj.Position = UDim2.new(globals.uiorigin.X.Scale,globals.uiorigin.X.Offset+change.X,globals.uiorigin.Y.Scale,globals.uiorigin.Y.Offset+change.Y)
  46. end
  47. end)
  48. end
  49.  
  50. function Create(obj, data)
  51. obj = Instance.new(obj)
  52. for i, v in pairs(data) do
  53. if i ~= "Parent" then
  54. obj[i] = v
  55. end
  56. end
  57. obj.Parent = data.Parent
  58. return obj
  59. end
  60.  
  61. function CreateTab(name, rainbow, color)
  62. tabcount = tabcount+1
  63. buttoncount[tabcount] = 0
  64. if rainbow then
  65. table.insert(rainbows,#rainbows+1,tabcount)
  66. color = Color3.new(1,0,0)
  67. elseif color == nil then
  68. color = Color3.new(1,0,0)
  69. end
  70. local tab = Create("Frame", {
  71. Name = tostring(tabcount),
  72. Parent = ui,
  73. Active = true,
  74. BackgroundColor3 = Color3.new(1, 1, 1),
  75. BackgroundTransparency = 1,
  76. Position = UDim2.new(0, (tabcount)*13+(tabcount-1)*200, 0.0128041022, 0),
  77. Size = UDim2.new(0, 200, 0, 40),
  78. })
  79. local top = Create("Frame", {
  80. Name = "Top",
  81. Parent = tab,
  82. BackgroundColor3 = Color3.new(0.117647, 0.117647, 0.117647),
  83. BorderColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314),
  84. BorderSizePixel = 3,
  85. Size = UDim2.new(1, 0, 1, -10),
  86. })
  87. local title = Create("TextLabel", {
  88. Parent = top,
  89. BackgroundTransparency = 1,
  90. Position = UDim2.new(0, 0, -0.006, 0),
  91. Size = UDim2.new(.035, 158, 1, 0),
  92. Font = Enum.Font.SourceSansSemibold,
  93. Text = name,
  94. TextColor3 = Color3.new(1, 1, 1),
  95. TextSize = 25,
  96. })
  97. local minimize = Create("TextButton", {
  98. Parent = top,
  99. BackgroundTransparency = 1,
  100. Position = UDim2.new(0.855, 0, 0.181, 0),
  101. Size = UDim2.new(0, 18, 0, 19),
  102. Font = Enum.Font.SourceSansSemibold,
  103. Text = "-",
  104. TextColor3 = Color3.new(1, 1, 1),
  105. TextSize = 35,
  106. })
  107. local rainbow = Create("Frame", {
  108. Parent = top,
  109. BackgroundColor3 = color,
  110. BorderSizePixel = 0,
  111. Position = UDim2.new(0, 0, 1, 0),
  112. Size = UDim2.new(1, 0, 0.07, 0),
  113. })
  114. local holder = Create("Frame", {
  115. Name = "ButtonHolder",
  116. Parent = tab,
  117. BackgroundTransparency = 1,
  118. ClipsDescendants = true,
  119. BorderSizePixel = 3,
  120. Position = UDim2.new(0, -3, 0.801999986, 0),
  121. Size = UDim2.new(0.0350000001, 200, 20, 0),
  122. })
  123. local holder2 = Create("Frame", {
  124. Name = "ButtonHolder",
  125. Parent = holder,
  126. BackgroundTransparency = 1,
  127. Position = UDim2.new(0, 3, 0, 0),
  128. Size = UDim2.new(0, 200, 0, 0),
  129. ZIndex = 0,
  130. })
  131. local holder3 = Create("Frame", {
  132. Parent = holder2,
  133. BackgroundColor3 = Color3.new(0.117647, 0.117647, 0.117647),
  134. BorderColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314),
  135. BorderSizePixel = 3,
  136. Position = UDim2.new(0, 0, 0, 0),
  137. Size = UDim2.new(0, 200, 0, 0),
  138. ZIndex = 0,
  139. })
  140. local debounce = false
  141. minimize.MouseButton1Click:Connect(function()
  142. if holder3.Visible then
  143. if debounce == false then
  144. debounce = true
  145. for i,v in pairs(holder3:GetChildren())do
  146. v.ZIndex=0
  147. end
  148. local tween = TweenService:Create(holder3,TweenInfo.new(.5),{["Position"]=UDim2.new(0, 0, 0, -1*(holder3.Size.Y.Offset+25))})
  149. tween:Play()
  150. tween.Completed:Connect(function()
  151. holder3.Visible = false
  152. debounce = false
  153. end)
  154. end
  155. else
  156. if debounce == false then
  157. debounce = true
  158. holder3.Visible = true
  159. local tween = TweenService:Create(holder3,TweenInfo.new(.5),{["Position"]=UDim2.new(0, 0, 0, 0)})
  160. tween:Play()
  161. tween.Completed:Connect(function()
  162. for i,v in pairs(holder3:GetChildren())do
  163. v.ZIndex=1
  164. debounce = false
  165. end
  166. end)
  167. end
  168. end
  169. end)
  170. draggable(tab)
  171. return tab
  172. end
  173.  
  174. function MakeButton(tab,text,callback)
  175. buttoncount[tonumber(tab.Name)] = buttoncount[tonumber(tab.Name)]+1
  176. local button = Create("TextButton", {
  177. Parent = tab.ButtonHolder.ButtonHolder.Frame,
  178. BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314),
  179. BorderSizePixel = 0,
  180. Position = UDim2.new(0.03, 0, 0, (buttoncount[tonumber(tab.Name)]-1)*42+6-(buttoncount[tonumber(tab.Name)]-1)*6),
  181. Size = UDim2.new(0, 188, 0, 30),
  182. Font = Enum.Font.SourceSansSemibold,
  183. Text = text,
  184. TextColor3 = Color3.new(1, 1, 1),
  185. TextSize = 25,
  186. })
  187. button.MouseButton1Click:Connect(function()
  188. callback(button)
  189. end)
  190. tab.ButtonHolder.ButtonHolder.Frame.BackgroundTransparency = 0
  191. tab.ButtonHolder.ButtonHolder.Frame.Size = UDim2.new(0, 200, 0, buttoncount[tonumber(tab.Name)]*42-(buttoncount[tonumber(tab.Name)]-1)*6)
  192. return button
  193. end
  194.  
  195. function MakeToggle(tab,text,default,callback)
  196. buttoncount[tonumber(tab.Name)] = buttoncount[tonumber(tab.Name)]+1
  197. local discordid326801946230915102bestslave
  198. if default then
  199. discordid326801946230915102bestslave = {"ON",Color3.new(0, 1, 0)}
  200. else
  201. discordid326801946230915102bestslave = {"OFF",Color3.new(1, 0, 0)}
  202. end
  203. local button = Create("TextButton", {
  204. Parent = tab.ButtonHolder.ButtonHolder.Frame,
  205. BackgroundColor3 = Color3.new(0.117647, 0.117647, 0.117647),
  206. BorderColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314),
  207. BorderSizePixel = 3,
  208. Position = UDim2.new(0.744999945, 0, 0, (buttoncount[tonumber(tab.Name)]-1)*42+6-(buttoncount[tonumber(tab.Name)]-1)*6),
  209. Size = UDim2.new(0, 45, 0, 30),
  210. ZIndex = 2,
  211. Font = Enum.Font.SourceSansSemibold,
  212. Text = discordid326801946230915102bestslave[1],
  213. TextColor3 = discordid326801946230915102bestslave[2],
  214. TextSize = 25,
  215. })
  216. local description = Create("TextLabel", {
  217. Parent = button,
  218. BackgroundColor3 = Color3.new(0.117647, 0.117647, 0.117647),
  219. BorderColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314),
  220. BorderSizePixel = 3,
  221. Position = UDim2.new(-3.18383813, 0, 0, 0),
  222. Size = UDim2.new(0, 143, 0, 30),
  223. ZIndex = 0,
  224. Font = Enum.Font.SourceSansSemibold,
  225. Text = text,
  226. TextColor3 = Color3.new(1, 1, 1),
  227. TextSize = 25,
  228. })
  229. tab.ButtonHolder.ButtonHolder.Frame.BackgroundTransparency = 0
  230. tab.ButtonHolder.ButtonHolder.Frame.Size = UDim2.new(0, 200, 0, buttoncount[tonumber(tab.Name)]*42-(buttoncount[tonumber(tab.Name)]-1)*6)
  231. button.MouseButton1Click:Connect(function()
  232. if button.Text == "ON" then
  233. button.Text = "OFF"
  234. button.TextColor3 = Color3.new(1, 0, 0)
  235. callback(button)
  236. else
  237. button.Text = "ON"
  238. button.TextColor3 = Color3.new(0, 1, 0)
  239. callback(button)
  240. end
  241. end)
  242. return button
  243. end
  244.  
  245. function MakeLabel(tab,text)
  246. buttoncount[tonumber(tab.Name)] = buttoncount[tonumber(tab.Name)]+1
  247. local label = Create("TextLabel", {
  248. Parent = tab.ButtonHolder.ButtonHolder.Frame,
  249. BackgroundTransparency = 1,
  250. Position = UDim2.new(0.03, 0, 0, (buttoncount[tonumber(tab.Name)]-1)*42+6-(buttoncount[tonumber(tab.Name)]-1)*6),
  251. Size = UDim2.new(0, 188, 0, 30),
  252. Font = Enum.Font.SourceSansSemibold,
  253. Text = text,
  254. TextColor3 = Color3.new(1, 1, 1),
  255. TextSize = 25,
  256. })
  257. tab.ButtonHolder.ButtonHolder.Frame.BackgroundTransparency = 0
  258. tab.ButtonHolder.ButtonHolder.Frame.Size = UDim2.new(0, 200, 0, buttoncount[tonumber(tab.Name)]*42-(buttoncount[tonumber(tab.Name)]-1)*6)
  259. return label
  260. end
  261.  
  262. function MakeBox(tab,text,placeholder,callback)
  263. buttoncount[tonumber(tab.Name)] = buttoncount[tonumber(tab.Name)]+1
  264. local fontsize
  265. if string.len(text) > 17 then
  266. fontsize = 25-(string.len(text)-17)
  267. else
  268. fontsize = 25
  269. end
  270. local label = Create("TextLabel", {
  271. Parent = tab.ButtonHolder.ButtonHolder.Frame,
  272. BackgroundTransparency = 1,
  273. Position = UDim2.new(0.03, 0, 0, (buttoncount[tonumber(tab.Name)]-1)*42+6-(buttoncount[tonumber(tab.Name)]-1)*6),
  274. Size = UDim2.new(0, 188, 0, 30),
  275. Font = Enum.Font.SourceSansSemibold,
  276. Text = text .. ":",
  277. TextColor3 = Color3.new(1, 1, 1),
  278. TextSize = fontsize,
  279. })
  280. buttoncount[tonumber(tab.Name)] = buttoncount[tonumber(tab.Name)]+1
  281. local box = Create("TextBox", {
  282. Parent = tab.ButtonHolder.ButtonHolder.Frame,
  283. BackgroundColor3 = Color3.new(0.0784314, 0.0784314, 0.078431),
  284. BorderSizePixel = 0,
  285. Position = UDim2.new(0.03, 0, 0, (buttoncount[tonumber(tab.Name)]-1)*42+6-(buttoncount[tonumber(tab.Name)]-1)*6),
  286. Size = UDim2.new(0, 188, 0, 30),
  287. Font = Enum.Font.SourceSansSemibold,
  288. PlaceholderText = placeholder,
  289. Text = "",
  290. TextColor3 = Color3.new(1, 1, 1),
  291. TextSize = 25,
  292. })
  293. box.FocusLost:Connect(function()
  294. callback(box)
  295. end)
  296. tab.ButtonHolder.ButtonHolder.Frame.BackgroundTransparency = 0
  297. tab.ButtonHolder.ButtonHolder.Frame.Size = UDim2.new(0, 200, 0, buttoncount[tonumber(tab.Name)]*42-(buttoncount[tonumber(tab.Name)]-1)*6)
  298. return box
  299. end
  300.  
  301. function MakeDropdown(tab,text,drops,default,callback)
  302. buttoncount[tonumber(tab.Name)] = buttoncount[tonumber(tab.Name)]+1
  303. local def = ""
  304. if default ~= nil or false then
  305. def = default
  306. end
  307. local label = Create("TextLabel", {
  308. Parent = tab.ButtonHolder.ButtonHolder.Frame,
  309. BackgroundTransparency = 1,
  310. Position = UDim2.new(0.03, 0, 0, (buttoncount[tonumber(tab.Name)]-1)*42+6-(buttoncount[tonumber(tab.Name)]-1)*6),
  311. Size = UDim2.new(0, 188, 0, 30),
  312. Font = Enum.Font.SourceSansSemibold,
  313. Text = text .. ":",
  314. TextColor3 = Color3.new(1, 1, 1),
  315. TextSize = 25,
  316. })
  317. buttoncount[tonumber(tab.Name)] = buttoncount[tonumber(tab.Name)]+1
  318. local frame = Create("Frame", {
  319. Parent = tab.ButtonHolder.ButtonHolder.Frame,
  320. BackgroundTransparency = 1,
  321. ClipsDescendants = true,
  322. Position = UDim2.new(0, -3, 0, (buttoncount[tonumber(tab.Name)]-1)*42+3-(buttoncount[tonumber(tab.Name)]-1)*6),
  323. Size = UDim2.new(0.0350000001, 200, 0, 785),
  324. })
  325. local frame2 = Create("Frame", {
  326. Parent = frame,
  327. BackgroundColor3 = Color3.new(0.117647, 0.117647, 0.117647),
  328. BorderColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314),
  329. BorderSizePixel = 3,
  330. Position = UDim2.new(0, 9, 0, 3),
  331. Size = UDim2.new(0, 188, 0, 30),
  332. })
  333. local selected = Create("TextLabel", {
  334. Parent = frame2,
  335. BackgroundTransparency = 1,
  336. Size = UDim2.new(0.84574461, 0, 1, 0),
  337. Font = Enum.Font.SourceSansSemibold,
  338. Text = def,
  339. TextColor3 = Color3.new(1, 1, 1),
  340. TextSize = 25,
  341. })
  342. local drop = Create("TextButton", {
  343. Parent = selected,
  344. BackgroundTransparency = 1,
  345. Position = UDim2.new(0.993710816, 0, 0.100000001, 0),
  346. Rotation = 90,
  347. Size = UDim2.new(0, 30, 0, 24),
  348. Font = Enum.Font.SourceSansSemibold,
  349. Text = ">",
  350. TextColor3 = Color3.new(1, 1, 1),
  351. TextSize = 25,
  352. TextWrapped = true,
  353. })
  354. local dropdowns = Create("Frame", {
  355. Parent = frame2,
  356. BackgroundColor3 = Color3.new(0.117647, 0.117647, 0.117647),
  357. BorderColor3 = Color3.new(0.0784314, 0.0784314, 0.0784314),
  358. BorderSizePixel = 3,
  359. Position = UDim2.new(0, 0, 0, 0),
  360. Size = UDim2.new(0, 188, 0, 0),
  361. ZIndex = 0,
  362. Visible = false
  363. })
  364. local debounce = false
  365. drop.MouseButton1Click:Connect(function()
  366. if dropdowns.Visible then
  367. if debounce == false then
  368. debounce = true
  369. for i,v in pairs(dropdowns:GetChildren())do
  370. v.ZIndex=0
  371. end
  372. local tween = TweenService:Create(dropdowns,TweenInfo.new(.5),{["Position"]=UDim2.new(0, 0, 0, -1*(dropdowns.Size.Y.Offset+25))})
  373. tween:Play()
  374. tween.Completed:Connect(function()
  375. dropdowns.Visible = false
  376. debounce = false
  377. end)
  378. end
  379. else
  380. if debounce == false then
  381. debounce = true
  382. dropdowns.Visible = true
  383. local tween = TweenService:Create(dropdowns,TweenInfo.new(.5),{["Position"]=UDim2.new(0, 0, 0, 0)})
  384. tween:Play()
  385. tween.Completed:Connect(function()
  386. for i,v in pairs(dropdowns:GetChildren())do
  387. v.ZIndex=1
  388. end
  389. debounce = false
  390. end)
  391. end
  392. end
  393. end)
  394. for i, v in pairs(drops) do
  395. local button = Create("TextButton", {
  396. Parent = dropdowns,
  397. BackgroundTransparency = 1,
  398. Position = UDim2.new(0, 0, 0, (i-1)*35+32-(i-1)*6),
  399. Size = UDim2.new(0, 188, 0, 29),
  400. Font = Enum.Font.SourceSansSemibold,
  401. Text = v,
  402. TextColor3 = Color3.new(1, 1, 1),
  403. TextSize = 20,
  404. })
  405. dropdowns.Size = UDim2.new(0, 188, 0, i*38)
  406. button.MouseButton1Click:Connect(function()
  407. selected.Text = button.Text
  408. callback(selected)
  409. if dropdowns.Visible then
  410. if debounce == false then
  411. debounce = true
  412. for i,v in pairs(dropdowns:GetChildren())do
  413. v.ZIndex=0
  414. end
  415. local tween = TweenService:Create(dropdowns,TweenInfo.new(.5),{["Position"]=UDim2.new(0, 0, 0, -1*(dropdowns.Size.Y.Offset+25))})
  416. tween:Play()
  417. tween.Completed:Connect(function()
  418. dropdowns.Visible = false
  419. debounce = false
  420. end)
  421. end
  422. else
  423. if debounce == false then
  424. debounce = true
  425. dropdowns.Visible = true
  426. local tween = TweenService:Create(dropdowns,TweenInfo.new(.5),{["Position"]=UDim2.new(0, 0, 0, 0)})
  427. tween:Play()
  428. tween.Completed:Connect(function()
  429. for i,v in pairs(dropdowns:GetChildren())do
  430. v.ZIndex=1
  431. end
  432. debounce = false
  433. end)
  434. end
  435. end
  436. end)
  437. end
  438. tab.ButtonHolder.ButtonHolder.Frame.BackgroundTransparency = 0
  439. tab.ButtonHolder.ButtonHolder.Frame.Size = UDim2.new(0, 200, 0, buttoncount[tonumber(tab.Name)]*42-(buttoncount[tonumber(tab.Name)]-1)*6)
  440. return selected
  441. end
  442.  
  443. game:GetService("RunService").RenderStepped:Connect(function()
  444. if #rainbows > 0 then
  445. color = Color3.fromHSV(math.acos(math.cos(rainbow*math.pi))/math.pi,.8,1)
  446. rainbow = rainbow + _G.breatherate
  447. for i, v in pairs(rainbows) do
  448. ui[v].Top.Frame.BackgroundColor3 = color
  449. end
  450. end
  451. end)
  452.  
  453. return library
Add Comment
Please, Sign In to add comment