Advertisement
trollhackerdude

ui lib

Sep 24th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. local lib = {
  2. windowcount = 0;
  3. maxCount = 2;
  4. maxSideObjects = 2;
  5. }
  6.  
  7.  
  8.  
  9. local plrs = game:GetService("Players")
  10. local plr = plrs.LocalPlayer
  11.  
  12.  
  13.  
  14. -- ugly code
  15. function lib:NewWindow(name)
  16. if not plr.PlayerGui:FindFirstChild("ui") then
  17. local parent = Instance.new("ScreenGui", plr.PlayerGui)
  18. parent.Name = "ui"
  19. end
  20. lib.windowcount = lib.windowcount + 1
  21. if lib.windowcount > lib.maxCount then
  22. plr:Kick("UI LIBRARY: Maximum window count is "..lib.maxCount)
  23. end
  24. local f = Instance.new("Frame")
  25. f.Name = name
  26. f.Size = UDim2.new(0,200,0,100)
  27. f.Parent = plr.PlayerGui.ui
  28. f.Active = true
  29. f.Draggable = true
  30. local val = Instance.new("IntValue",f)
  31. val.Name = "obj"
  32. val.Value = 0
  33. local label = Instance.new("TextLabel", f)
  34. label.Name = "label"
  35. label.Text = name -- make sure you dont dick off when naming your frames
  36. label.Position = UDim2.new(0,0,0,0)
  37. label.Size = UDim2.new(0,200,0,20)
  38. if lib.windowcount == 1 then
  39. f.Position = UDim2.new(0,0,0,0)
  40. elseif lib.windowcount == 2 then
  41. f.Position = UDim2.new(0.267,0,0,0)
  42. end
  43. f.BackgroundColor3 = Color3.new(130,130,130)
  44. end
  45.  
  46. function lib:NewObject(class, name, object)
  47.  
  48. local parent = plr.PlayerGui.ui:FindFirstChild(object)
  49.  
  50. if not parent:FindFirstChild("obj") then
  51. plr:Kick("LIBRARY: Invalid Parent for object, parent must be a valid frame created by library and have the obj int value in it")
  52. end
  53.  
  54. local val = parent.obj
  55.  
  56. val.Value = val.Value + 1
  57.  
  58. if val.Value >= 4 then
  59. plr:Kick("UI LIBRARY: Too many objects in one gui, the max is 3.")
  60. end
  61.  
  62. local main = Instance.new(class)
  63. main.Name = name
  64. main.Parent = parent
  65.  
  66. main.Size = UDim2.new(0,180,0,20)
  67. main.Text = name
  68.  
  69. if val.Value == 1 then
  70. main.Position = UDim2.new(0.05, 0,0.25, 0)
  71.  
  72. elseif val.Value == 2 then
  73. main.Position = UDim2.new(0.05, 0,0.5, 0)
  74.  
  75. elseif val.Value == 3 then
  76. main.Position = UDim2.new(0.05, 0,0.75, 0)
  77.  
  78.  
  79.  
  80. end
  81.  
  82.  
  83. end
  84.  
  85.  
  86.  
  87. return lib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement