Advertisement
zqozr

ui library 0.4

Aug 25th, 2021 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.51 KB | None | 0 0
  1. --[[
  2. - HOW TO USE:
  3. first line:
  4. local library = loadstring(game:HttpGet('https://pastebin.com/raw/mwSUiuAD'))()
  5. local frame = library.create_frame('framename', 5) -- the argument_2(fitsize) is how much textlabels + text buttons can fit in the frame.
  6. local textlabel1 = frame.add_textlabel("zq's test ui library") -- btw, this function returns the textlabel you create
  7. local textbutton1 = frame.add_textbutton("print a msg", function() print("testing") game:GetService("StarterGui") end) -- the second argument will be the function onclick, this funtion also returns the textbutton you create
  8. ]]
  9.  
  10. local library = {}
  11. local frames = {}
  12. local close_bind_key = Enum.KeyCode.RightShift
  13. local close_bind_bool = true
  14. local base = Instance.new("ScreenGui")
  15. base.Parent=game:GetService("CoreGui")
  16. base.Name = "zq's library."
  17.  
  18. function library.create_frame(frame_name, fitsize) -- the argument_2(fitsize) is how much textlabels + text buttons can fit in the frame.
  19.     local frame_library = {}
  20.     table.insert(frames, frame_library)
  21.     local count = 0
  22.     local frame = Instance.new("Frame")
  23.     frame.Parent=base
  24.     frame.Name=frame_name
  25.     frame.Active = true
  26.     frame.Draggable = true
  27.     frame.BackgroundColor3=Color3.new(0.0980392, 0.0980392, 0.0980392)
  28.     coroutine.resume(coroutine.create(function()
  29.         local fitcount = 0
  30.         for i = 1, fitsize, 1 do
  31.             fitcount+=0.05
  32.         end
  33.         frame.Size=UDim2.new(0.128, 0, fitcount, 0)
  34.     end))
  35.     local listlayout = Instance.new("UIListLayout")
  36.     listlayout.Parent=frame
  37.    
  38.     function frame_library.getframe()
  39.         return frame
  40.     end
  41.    
  42.     function frame_library.add_textlabel(text)
  43.         if count<fitsize then
  44.             count+=1
  45.             local textlabel = Instance.new("TextLabel")
  46.             textlabel.Parent=frame
  47.             textlabel.Size=UDim2.new(1, 0, frame.Size.Y.Scale/4, 0)
  48.             textlabel.BackgroundTransparency=Color3.new(0.2, 0.2, 0.2)
  49.             textlabel.TextScaled=true
  50.             textlabel.Font = Enum.Font.ArialBold
  51.             textlabel.Text = text
  52.             textlabel.TextColor3=Color3.new(0.501961, 0.999969, 0.0310369)
  53.             return textlabel
  54.         else
  55.             game:GetService('CoreGui'):SetCore("SendNotification", {
  56.                 Title = 'Error!';
  57.                 Text = 'count<fitsize, new textlabel denied';
  58.                 Duration = 15;
  59.             })
  60.         end
  61.         return false
  62.     end
  63.    
  64.     function frame_library.add_textbutton(text, func)
  65.         if count<fitsize then
  66.             count+=1
  67.             local textbutton = Instance.new("TextButton")
  68.             textbutton.Parent=frame
  69.             textbutton.Size=UDim2.new(1, 0, frame.Size.Y.Scale/4, 0)
  70.             textbutton.BackgroundTransparency=Color3.new(0.2, 0.2, 0.2)
  71.             textbutton.TextScaled=true
  72.             textbutton.Font = Enum.Font.ArialBold
  73.             textbutton.Text = text
  74.             textbutton.TextColor3=Color3.new(0.701961, 0.701961, 0.701961)
  75.             if func then
  76.                 textbutton.MouseButton1Click:Connect(func)
  77.             end
  78.             return textbutton
  79.         else
  80.             game:GetService('CoreGui'):SetCore("SendNotification", {
  81.                 Title = 'Error!';
  82.                 Text = 'count<fitsize, new textbutton denied';
  83.                 Duration = 15;
  84.             })
  85.         end
  86.     end
  87.     return frame_library
  88. end
  89.  
  90. function library.getallframes()
  91.     return frames
  92. end
  93.  
  94. function library.bindtoclose(bool, keybind) -- keybind has to be a enum. Like, Enum.KeyCode.E, Enum.KeyCode.RightShift
  95.     if bool == true then
  96.         close_bind_bool = true
  97.         close_bind_key = keybind
  98.     else
  99.         close_bind_bool = false
  100.     end
  101. end
  102.  
  103. game:GetService("UserInputService").InputBegan:Connect(function(inp, gps)
  104.     if inp.KeyCode==close_bind_key and close_bind_bool==true then
  105.         for _, v in pairs(frames) do
  106.             local rframe = v.getframe()
  107.             rframe.Visible = not rframe.Visible
  108.         end
  109.     end
  110. end)
  111.  
  112.  
  113. return library
  114.  
  115.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement