Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.95 KB | None | 0 0
  1. local levimatlib = {}
  2. local mouse = game.Players.LocalPlayer:GetMouse()
  3. local ts = game:GetService("TweenService")
  4.  
  5. function levimatlib:CreateGui(title, sizex, sizey, mainColor, accentColor)
  6. local gui = {}
  7. local Material = Instance.new("ScreenGui")
  8. local MainFrame = Instance.new("Frame")
  9. local DragFrame = Instance.new("Frame")
  10. local TitleFrame = Instance.new("Frame")
  11. local TextLabel = Instance.new("TextLabel")
  12. local Content = Instance.new("Frame")
  13. local UIGridLayout = Instance.new("UIGridLayout")
  14.  
  15. Material.Name = "Material"
  16. Material.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  17. Material.ResetOnSpawn = false
  18.  
  19. MainFrame.Name = "MainFrame"
  20. MainFrame.Parent = Material
  21. MainFrame.BackgroundColor3 = Color3.new(1, 1, 1)
  22. MainFrame.BackgroundTransparency = 1
  23. MainFrame.BorderSizePixel = 0
  24. MainFrame.ClipsDescendants = true
  25. MainFrame.Position = UDim2.new(0.25, 0, 0.25, 0)
  26. MainFrame.Size = UDim2.new(0, sizex, 0, sizey)
  27. MainFrame.AnchorPoint = Vector2.new(0.5,0.05)
  28.  
  29. DragFrame.Name = "DragFrame"
  30. DragFrame.Parent = MainFrame
  31. DragFrame.BackgroundColor3 = accentColor
  32. DragFrame.BorderSizePixel = 0
  33. DragFrame.ClipsDescendants = true
  34. DragFrame.Size = UDim2.new(1, 0, 0, 10)
  35.  
  36. TitleFrame.Name = "TitleFrame"
  37. TitleFrame.Parent = MainFrame
  38. TitleFrame.BackgroundColor3 = mainColor
  39. TitleFrame.BorderSizePixel = 0
  40. TitleFrame.ClipsDescendants = true
  41. TitleFrame.Position = UDim2.new(0, 0, 0, 10)
  42. TitleFrame.Size = UDim2.new(1, 0, 0, 40)
  43.  
  44. TextLabel.Parent = TitleFrame
  45. TextLabel.BackgroundColor3 = Color3.new(1, 1, 1)
  46. TextLabel.BackgroundTransparency = 1
  47. TextLabel.Position = UDim2.new(0, 20, 0, 0)
  48. TextLabel.Size = UDim2.new(0, 150, 1, 0)
  49. TextLabel.Font = Enum.Font.SourceSans
  50. TextLabel.FontSize = Enum.FontSize.Size24
  51. TextLabel.Text = title
  52. TextLabel.TextColor3 = Color3.new(1, 1, 1)
  53. TextLabel.TextSize = 24
  54. TextLabel.TextStrokeColor3 = Color3.new(1, 1, 1)
  55. TextLabel.TextWrapped = true
  56. TextLabel.TextXAlignment = Enum.TextXAlignment.Left
  57.  
  58. Content.Name = "Content"
  59. Content.Parent = MainFrame
  60. Content.BackgroundColor3 = Color3.new(1, 1, 1)
  61. Content.BorderSizePixel = 0
  62. Content.ClipsDescendants = true
  63. Content.Position = UDim2.new(0, 0, 0, 50)
  64. Content.Size = UDim2.new(1, 0, 1, -50)
  65.  
  66. UIGridLayout.Parent = Content
  67. UIGridLayout.CellPadding = UDim2.new(0, 0, 0, 0)
  68. UIGridLayout.CellSize = UDim2.new(0, sizex/2, 0.2, 0)
  69. UIGridLayout.FillDirection = Enum.FillDirection.Vertical
  70. UIGridLayout.SortOrder = Enum.SortOrder.LayoutOrder
  71.  
  72.  
  73. local mouseondrag = false
  74. DragFrame.MouseEnter:connect(function()
  75. mouseondrag = true
  76. end)
  77. DragFrame.MouseLeave:connect(function()
  78. mouseondrag = false
  79. end)
  80.  
  81. local mousedown = false
  82. mouse.Button1Down:connect(function()
  83. if mouseondrag == true then
  84. mousedown = true
  85. end
  86. end)
  87. mouse.Button1Up:connect(function()
  88. mousedown = false
  89. end)
  90.  
  91. spawn(function()
  92. while true do
  93. if mousedown == true then
  94. local goal = UDim2.new(0, mouse.X, 0, mouse.Y)
  95. MainFrame:TweenPosition(goal, nil, Enum.EasingStyle.Sine, nil, 0.05)
  96. end
  97. wait(.1)
  98. end
  99. end)
  100.  
  101.  
  102.  
  103. function gui:SetColor(newmainColor,newaccentColor)
  104. mainColor = newmainColor
  105. accentColor = newaccentColor
  106.  
  107. TitleFrame.BackgroundColor3 = newmainColor
  108. DragFrame.BackgroundColor3 = newaccentColor
  109.  
  110. local contents = Content:GetDescendants()
  111. for i=1,#contents do
  112. if contents[i].ClassName == "TextLabel" then
  113. contents[i].TextColor3 = newmainColor
  114. end
  115. if contents[i].ClassName == "TextButton" then
  116. contents[i].TextColor3 = newmainColor
  117. end
  118. if contents[i].ClassName == "TextBox" then
  119. contents[i].TextColor3 = newmainColor
  120. end
  121. if contents[i].Name == "Grabber" then
  122. contents[i].BackgroundColor3 = newmainColor
  123. contents[i].BorderColor3 = newaccentColor
  124. end
  125. if contents[i].Name == "SliderFill" then
  126. contents[i].BackgroundColor3 = newmainColor
  127. end
  128. if contents[i].Name == "Animation" then
  129. contents[i].BackgroundColor3 = newmainColor
  130. end
  131. end
  132. end
  133.  
  134. local animation = Instance.new("Frame")
  135. animation.Name = "Animation"
  136. animation.AnchorPoint = Vector2.new(0.5,0.5)
  137. animation.BackgroundColor3 = accentColor
  138. animation.BackgroundTransparency = 0.6
  139. animation.BorderSizePixel = 0
  140. animation.Visible = false
  141. local tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)
  142. local goal = {}
  143. goal.Size = UDim2.new(0, 0, 0, 0)
  144. local tween = ts:Create(animation, tweeninfo, goal)
  145.  
  146. function gui:CreateAnimation(parent, mode)
  147. animation.Parent = parent
  148. tween:Cancel()
  149. if mode == 1 then
  150. goal.Size = UDim2.new(0, 0, 0, 0)
  151. goal.Transparency = 0.6
  152. animation.BackgroundTransparency = 0.6
  153. tween = ts:Create(animation, tweeninfo, goal)
  154. elseif mode == 2 then
  155. goal.Size = UDim2.new(0, 1000, 0, 1000)
  156. goal.Transparency = 1
  157. tween = ts:Create(animation, tweeninfo, goal)
  158. end
  159. local x = (mouse.X) - (parent.AbsolutePosition.X)
  160. local y = (mouse.Y) - (parent.AbsolutePosition.Y)
  161. animation.Position = UDim2.new(0, x, 0, y)
  162. animation.Size = UDim2.new(0, 50, 0, 50)
  163. animation.Visible = true
  164. tween:Play()
  165. end
  166.  
  167.  
  168. function gui:CreateButton(text, func)
  169. if func == nil then
  170. print("no func added!")
  171. else
  172. local ButtonHolder = Instance.new("Frame")
  173. local TextButton = Instance.new("TextButton")
  174.  
  175. ButtonHolder.Name = "ButtonHolder"
  176. ButtonHolder.Parent = Content
  177. ButtonHolder.BackgroundColor3 = Color3.new(1, 1, 1)
  178. ButtonHolder.BackgroundTransparency = 1
  179. ButtonHolder.ClipsDescendants = true
  180. ButtonHolder.Position = UDim2.new(0, 0, 0.2, 0)
  181. ButtonHolder.Size = UDim2.new(0.5, 0, 0.2, 0)
  182.  
  183. TextButton.Parent = ButtonHolder
  184. TextButton.BackgroundColor3 = Color3.new(0.941176, 0.941176, 0.941176)
  185. TextButton.BorderSizePixel = 0
  186. TextButton.ClipsDescendants = true
  187. TextButton.Position = UDim2.new(0.1, 0, 0.1, 0)
  188. TextButton.Size = UDim2.new(0.8, 0, 0.8, 0)
  189. TextButton.Font = Enum.Font.SourceSansBold
  190. TextButton.FontSize = Enum.FontSize.Size18
  191. TextButton.Text = text
  192. TextButton.TextColor3 = mainColor
  193. TextButton.TextSize = 16
  194.  
  195. TextButton.MouseButton1Down:connect(function()
  196. gui:CreateAnimation(TextButton, 1)
  197. end)
  198.  
  199.  
  200. TextButton.MouseButton1Up:connect(function()
  201. func()
  202. gui:CreateAnimation(TextButton, 2)
  203. end)
  204.  
  205.  
  206. end
  207. end
  208.  
  209. function gui:CreateCheckbox(text, defaultstate)
  210. if defaultstate == true then
  211. toggled = true
  212. else
  213. toggled = false
  214. end
  215.  
  216. local CheckboxHolder = Instance.new("Frame")
  217. local CheckboxUnderline = Instance.new("Frame")
  218. local Label = Instance.new("TextLabel")
  219. local Checkbox = Instance.new("TextLabel")
  220.  
  221. CheckboxHolder.Name = "CheckboxHolder"
  222. CheckboxHolder.Parent = Content
  223. CheckboxHolder.BackgroundColor3 = Color3.new(1, 1, 1)
  224. CheckboxHolder.BackgroundTransparency = 1
  225. CheckboxHolder.ClipsDescendants = true
  226. CheckboxHolder.Position = UDim2.new(0, 0, 0.8, 0)
  227. CheckboxHolder.Size = UDim2.new(0.5, 0, 0.2, 0)
  228.  
  229. Label.Name = "Label"
  230. Label.Parent = CheckboxHolder
  231. Label.BackgroundColor3 = Color3.new(1, 1, 1)
  232. Label.BackgroundTransparency = 1
  233. Label.BorderSizePixel = 0
  234. Label.ClipsDescendants = true
  235. Label.Position = UDim2.new(0.1, 0, 0.1, 0)
  236. Label.Size = UDim2.new(0.8, 0, 0.8, 0)
  237. Label.Font = Enum.Font.SourceSansBold
  238. Label.FontSize = Enum.FontSize.Size18
  239. Label.Text = text
  240. Label.TextColor3 = mainColor
  241. Label.TextSize = 18
  242. Label.TextXAlignment = Enum.TextXAlignment.Left
  243.  
  244. Checkbox.Name = "Checkbox"
  245. Checkbox.Parent = CheckboxHolder
  246. Checkbox.BackgroundColor3 = Color3.new(1, 1, 1)
  247. Checkbox.BorderColor3 = Color3.fromRGB(60, 60, 60)
  248. Checkbox.ClipsDescendants = true
  249. Checkbox.Position = UDim2.new(0.8, 0, 0.1, 0)
  250. Checkbox.Size = UDim2.new(0, 20, 0, 20)
  251. Checkbox.Font = Enum.Font.SourceSansBold
  252. Checkbox.FontSize = Enum.FontSize.Size18
  253. if toggled == true then
  254. Checkbox.Text = "✓"
  255. else
  256. Checkbox.Text = "X"
  257. end
  258. Checkbox.TextColor3 = mainColor
  259. Checkbox.TextScaled = true
  260. Checkbox.TextSize = 16
  261. Checkbox.TextWrapped = true
  262.  
  263. local mouseoncheckbox = false
  264. Checkbox.MouseEnter:connect(function()
  265. mouseoncheckbox = true
  266. end)
  267. Checkbox.MouseLeave:connect(function()
  268. mouseoncheckbox = false
  269. end)
  270.  
  271. mouse.Button1Down:connect(function()
  272. if mouseoncheckbox == true then
  273. gui:CreateAnimation(Checkbox, 1)
  274. end
  275. end)
  276.  
  277. mouse.Button1Up:connect(function()
  278. if mouseoncheckbox == true then
  279. gui:CreateAnimation(Checkbox, 2)
  280. if toggled == true then
  281. toggled = false
  282. Checkbox.Text = "X"
  283. else
  284. toggled = true
  285. Checkbox.Text = "✓"
  286. end
  287. end
  288. end)
  289.  
  290. local subfunction = {}
  291.  
  292. function subfunction:GetValue()
  293. if toggled == true then
  294. return true
  295. else
  296. return false
  297. end
  298. end
  299. return subfunction
  300. end
  301.  
  302.  
  303. function gui:CreateTextbox(text)
  304. local TextboxHolder = Instance.new("Frame")
  305. local TextboxUnderline = Instance.new("Frame")
  306. local TextBox = Instance.new("TextBox")
  307.  
  308. TextboxHolder.Name = "TextboxHolder"
  309. TextboxHolder.Parent = Content
  310. TextboxHolder.BackgroundColor3 = Color3.new(1, 1, 1)
  311. TextboxHolder.BackgroundTransparency = 1
  312. TextboxHolder.ClipsDescendants = true
  313. TextboxHolder.Position = UDim2.new(0, 0, 0.4, 0)
  314. TextboxHolder.Size = UDim2.new(0.5, 0, 0.2, 0)
  315.  
  316. TextboxUnderline.Name = "TextboxUnderline"
  317. TextboxUnderline.Parent = TextboxHolder
  318. TextboxUnderline.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
  319. TextboxUnderline.BorderSizePixel = 0
  320. TextboxUnderline.ClipsDescendants = true
  321. TextboxUnderline.Position = UDim2.new(0.1, 0, 0.9, 0)
  322. TextboxUnderline.Size = UDim2.new(0.8, 0, 0, 1)
  323.  
  324. TextBox.Parent = TextboxHolder
  325. TextBox.BackgroundColor3 = Color3.new(1, 1, 1)
  326. TextBox.BackgroundTransparency = 1
  327. TextBox.BorderSizePixel = 0
  328. TextBox.ClipsDescendants = true
  329. TextBox.Position = UDim2.new(0.1, 0, 0.1, 0)
  330. TextBox.Size = UDim2.new(0.8, 0, 0.8, 0)
  331. TextBox.Font = Enum.Font.SourceSansBold
  332. TextBox.FontSize = Enum.FontSize.Size18
  333. TextBox.TextColor3 = mainColor
  334. TextBox.TextSize = 18
  335. TextBox.TextXAlignment = Enum.TextXAlignment.Left
  336. TextBox.Text = text
  337.  
  338. TextBox.Focused:connect(function()
  339. TextboxUnderline.BackgroundColor3 = mainColor
  340. end)
  341.  
  342. TextBox.FocusLost:connect(function()
  343. TextboxUnderline.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
  344. end)
  345.  
  346. local subfunction = {}
  347.  
  348. function subfunction:GetText()
  349. return TextBox.Text
  350. end
  351. return subfunction
  352. end
  353.  
  354.  
  355. function gui:CreateSlider(defaultvalue)
  356. local value = 0
  357. if defaultvalue == nil or defaultvalue <= 0 then
  358. value = 0
  359. elseif defaultvalue >= 100 then
  360. value = 100
  361. else
  362. value = defaultvalue
  363. end
  364.  
  365.  
  366. local SliderHolder = Instance.new("Frame")
  367. local SliderBackground = Instance.new("Frame")
  368. local SliderFill = Instance.new("Frame")
  369. local Grabber = Instance.new("Frame")
  370.  
  371. SliderHolder.Name = "SliderHolder"
  372. SliderHolder.Parent = Content
  373. SliderHolder.BackgroundColor3 = Color3.new(1, 1, 1)
  374. SliderHolder.BackgroundTransparency = 1
  375. SliderHolder.ClipsDescendants = true
  376. SliderHolder.Size = UDim2.new(0.5, 0, 0.2, 0)
  377.  
  378. SliderBackground.Name = "SliderBackground"
  379. SliderBackground.Parent = SliderHolder
  380. SliderBackground.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
  381. SliderBackground.BorderSizePixel = 0
  382. SliderBackground.ClipsDescendants = true
  383. SliderBackground.Position = UDim2.new(0.1, 0, 0.5, 0)
  384. SliderBackground.Size = UDim2.new(0.8, 0, 0, 2)
  385.  
  386. SliderFill.Name = "SliderFill"
  387. SliderFill.Parent = SliderHolder
  388. SliderFill.BackgroundColor3 = mainColor
  389. SliderFill.BorderSizePixel = 0
  390. SliderFill.ClipsDescendants = true
  391. SliderFill.Position = UDim2.new(0.1, 0, 0.5, 0)
  392. SliderFill.Size = UDim2.new(0, 0, 0, 2)
  393. SliderFill.ZIndex = 2
  394.  
  395. local goal2 = UDim2.new(0, 150*(value/100), 0, 2)
  396. SliderFill:TweenSize(goal2, nil, Enum.EasingStyle.Sine, nil, 0.05)
  397.  
  398.  
  399. Grabber.Name = "Grabber"
  400. Grabber.Parent = SliderHolder
  401. Grabber.BackgroundColor3 = mainColor
  402. Grabber.BorderColor3 = accentColor
  403. Grabber.ClipsDescendants = true
  404. Grabber.AnchorPoint = Vector2.new(0.5,0.5)
  405. Grabber.Position = UDim2.new(0, 150*(value/100) + 25, 0.5, 0)
  406. Grabber.Size = UDim2.new(0, 10, 0, 10)
  407. Grabber.ZIndex = 3
  408.  
  409. local mouseongrabber = false
  410. Grabber.MouseEnter:connect(function()
  411. mouseongrabber = true
  412. end)
  413. Grabber.MouseLeave:connect(function()
  414. mouseongrabber = false
  415. end)
  416.  
  417. local dragginggrabber = false
  418. mouse.Button1Down:connect(function()
  419. if mouseongrabber == true then
  420. dragginggrabber = true
  421. end
  422. end)
  423.  
  424. mouse.Button1Up:connect(function()
  425. dragginggrabber = false
  426. end)
  427.  
  428.  
  429. spawn(function()
  430. local thesizex = (sizex/2)-50
  431. while true do
  432.  
  433.  
  434. if Grabber.Position.X.Offset >= 178 then
  435. dragginggrabber = false
  436. Grabber:TweenPosition(UDim2.new(Grabber.Position.X.Scale, thesizex+25, Grabber.Position.Y.Scale, 0), 'Out', Enum.EasingStyle.Linear, 0.1, true)
  437. SliderFill:TweenSize(UDim2.new(0, 150, 0, 2), 'Out', Enum.EasingStyle.Linear, 0.1, true)
  438. end
  439. if Grabber.Position.X.Offset <= 22 then
  440. dragginggrabber = false
  441. Grabber:TweenPosition(UDim2.new(Grabber.Position.X.Scale, 25, Grabber.Position.Y.Scale, 0), 'Out', Enum.EasingStyle.Linear, 0.1, true)
  442. SliderFill:TweenSize(UDim2.new(0, 0, 0, 2), 'Out', Enum.EasingStyle.Linear, 0.1, true)
  443. end
  444.  
  445. if dragginggrabber == true then
  446. local pos = (mouse.X) - (SliderHolder.AbsolutePosition.X)
  447. if pos <= 15 then
  448. pos = 25
  449. end
  450. if pos >= thesizex+35 then
  451. pos = thesizex+25
  452. end
  453.  
  454. local goal = UDim2.new(0, pos, 0.5, 0)
  455. Grabber:TweenPosition(goal, 'Out', Enum.EasingStyle.Linear, 0.1, true)
  456. local goal2 = UDim2.new(0, pos-25, 0, 2)
  457. SliderFill:TweenSize(goal2, 'Out', Enum.EasingStyle.Linear, 0.1, true)
  458. end
  459. wait()
  460. end
  461. end)
  462.  
  463.  
  464.  
  465. local subfunction = {}
  466.  
  467. function subfunction:GetValue()
  468. if 0 >= SliderFill.Size.X.Offset/thesizex*50 then
  469. return 0
  470. else
  471. if SliderFill.Size.X.Offset/thesizex*100 >= 50 then
  472. return 100
  473. else
  474. return SliderFill.Size.X.Offset/thesizex*50
  475. end
  476. end
  477. end
  478. return subfunction
  479. end
  480.  
  481.  
  482.  
  483. return gui
  484. end
  485.  
  486. return levimatlib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement