w3vu2m81e912ce7m

my lib ezzz

Jan 20th, 2026 (edited)
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.04 KB | None | 0 0
  1. --// Clean Universal UI Library (FULL, ALIGNED, SQUARE TABS)
  2. local Lib = {}
  3. Lib.__index = Lib
  4.  
  5. -- Services
  6. local Players = game:GetService("Players")
  7. local TweenService = game:GetService("TweenService")
  8. local LocalPlayer = Players.LocalPlayer
  9.  
  10. -- Constants
  11. local ROW_HEIGHT = 36
  12. local PADDING = 12
  13. local SPACING = 8
  14.  
  15. -- Create Window
  16. function Lib:CreateWindow(cfg)
  17. local self = setmetatable({}, Lib)
  18.  
  19. local gui = Instance.new("ScreenGui")
  20. gui.Name = "UILibrary"
  21. gui.ResetOnSpawn = false
  22. gui.Parent = LocalPlayer:WaitForChild("PlayerGui")
  23. self.Gui = gui
  24.  
  25. local main = Instance.new("Frame", gui)
  26. main.Size = UDim2.fromOffset(cfg.SizeX or 550, cfg.SizeY or 450)
  27. main.Position = UDim2.fromScale(0.5,0.5)
  28. main.AnchorPoint = Vector2.new(0.5,0.5)
  29. main.BackgroundColor3 = Color3.fromRGB(25,25,30)
  30. main.BorderSizePixel = 0
  31. self.Main = main
  32. Instance.new("UICorner", main).CornerRadius = UDim.new(0,8)
  33.  
  34. -- Title bar
  35. local title = Instance.new("TextLabel", main)
  36. title.Size = UDim2.new(1,0,0,44)
  37. title.BackgroundColor3 = Color3.fromRGB(30,30,40)
  38. title.BorderSizePixel = 0
  39. title.Text = " "..(cfg.Title or "UI")
  40. title.TextXAlignment = Left
  41. title.Font = Enum.Font.GothamBold
  42. title.TextSize = 18
  43. title.TextColor3 = Color3.fromRGB(230,230,240)
  44.  
  45. -- Tabs
  46. local tabBar = Instance.new("Frame", main)
  47. tabBar.Position = UDim2.new(0,10,0,54)
  48. tabBar.Size = UDim2.new(0,140,1,-64)
  49. tabBar.BackgroundTransparency = 1
  50. self.TabBar = tabBar
  51.  
  52. local tabLayout = Instance.new("UIListLayout", tabBar)
  53. tabLayout.Padding = UDim.new(0,6)
  54.  
  55. -- Content
  56. local content = Instance.new("Frame", main)
  57. content.Position = UDim2.new(0,160,0,54)
  58. content.Size = UDim2.new(1,-170,1,-64)
  59. content.BackgroundTransparency = 1
  60. self.Content = content
  61.  
  62. self.SelectedTab = nil
  63. return self
  64. end
  65.  
  66. -- Add Tab (Square)
  67. function Lib:AddTab(name)
  68. local tab = {}
  69.  
  70. local btn = Instance.new("TextButton", self.TabBar)
  71. btn.Size = UDim2.new(1,0,0,40)
  72. btn.BackgroundColor3 = Color3.fromRGB(40,40,55)
  73. btn.Text = name
  74. btn.Font = Enum.Font.GothamSemibold
  75. btn.TextSize = 14
  76. btn.TextColor3 = Color3.fromRGB(210,210,230)
  77. btn.AutoButtonColor = false
  78.  
  79. local page = Instance.new("ScrollingFrame", self.Content)
  80. page.Size = UDim2.new(1,0,1,0)
  81. page.ScrollBarThickness = 4
  82. page.Visible = false
  83. page.CanvasSize = UDim2.new(0,0,0,0)
  84. page.BackgroundTransparency = 1
  85.  
  86. local pad = Instance.new("UIPadding", page)
  87. pad.PaddingLeft = UDim.new(0,PADDING)
  88. pad.PaddingRight = UDim.new(0,PADDING)
  89. pad.PaddingTop = UDim.new(0,PADDING)
  90.  
  91. local layout = Instance.new("UIListLayout", page)
  92. layout.Padding = UDim.new(0,SPACING)
  93.  
  94. layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
  95. page.CanvasSize = UDim2.new(0,0,0,layout.AbsoluteContentSize.Y + 10)
  96. end)
  97.  
  98. btn.MouseButton1Click:Connect(function()
  99. if self.SelectedTab then
  100. self.SelectedTab.Page.Visible = false
  101. self.SelectedTab.Button.BackgroundColor3 = Color3.fromRGB(40,40,55)
  102. end
  103. page.Visible = true
  104. btn.BackgroundColor3 = Color3.fromRGB(60,60,85)
  105. self.SelectedTab = tab
  106. end)
  107.  
  108. if not self.SelectedTab then
  109. self.SelectedTab = tab
  110. page.Visible = true
  111. btn.BackgroundColor3 = Color3.fromRGB(60,60,85)
  112. end
  113.  
  114. tab.Button = btn
  115. tab.Page = page
  116.  
  117. -- Toggle
  118. function tab:AddToggle(text, default, cb)
  119. local row = Instance.new("Frame", page)
  120. row.Size = UDim2.new(1,0,0,ROW_HEIGHT)
  121. row.BackgroundTransparency = 1
  122.  
  123. local label = Instance.new("TextLabel", row)
  124. label.Size = UDim2.new(1,-70,1,0)
  125. label.BackgroundTransparency = 1
  126. label.Text = text
  127. label.Font = Enum.Font.Gotham
  128. label.TextSize = 14
  129. label.TextXAlignment = Left
  130. label.TextColor3 = Color3.fromRGB(230,230,240)
  131.  
  132. local toggle = Instance.new("TextButton", row)
  133. toggle.Size = UDim2.fromOffset(56,24)
  134. toggle.Position = UDim2.new(1,-56,0.5,-12)
  135. toggle.Font = Enum.Font.GothamBold
  136. toggle.TextSize = 12
  137. toggle.TextColor3 = Color3.new(1,1,1)
  138. toggle.AutoButtonColor = false
  139.  
  140. local state = default
  141. local function draw()
  142. toggle.Text = state and "ON" or "OFF"
  143. toggle.BackgroundColor3 = state and Color3.fromRGB(80,200,120) or Color3.fromRGB(70,70,90)
  144. end
  145. draw()
  146.  
  147. toggle.MouseButton1Click:Connect(function()
  148. state = not state
  149. draw()
  150. if cb then cb(state) end
  151. end)
  152. end
  153.  
  154. -- Slider
  155. function tab:AddSlider(text,min,max,default,cb)
  156. local row = Instance.new("Frame", page)
  157. row.Size = UDim2.new(1,0,0,ROW_HEIGHT+10)
  158. row.BackgroundTransparency = 1
  159.  
  160. local label = Instance.new("TextLabel", row)
  161. label.Size = UDim2.new(1,0,0,18)
  162. label.BackgroundTransparency = 1
  163. label.Text = text.." ("..default..")"
  164. label.Font = Enum.Font.Gotham
  165. label.TextSize = 13
  166. label.TextXAlignment = Left
  167. label.TextColor3 = Color3.fromRGB(220,220,235)
  168.  
  169. local bar = Instance.new("Frame", row)
  170. bar.Position = UDim2.new(0,0,0,24)
  171. bar.Size = UDim2.new(1,0,0,6)
  172. bar.BackgroundColor3 = Color3.fromRGB(60,60,80)
  173.  
  174. local fill = Instance.new("Frame", bar)
  175. fill.Size = UDim2.new((default-min)/(max-min),0,1,0)
  176. fill.BackgroundColor3 = Color3.fromRGB(120,140,255)
  177.  
  178. bar.InputBegan:Connect(function(i)
  179. if i.UserInputType == Enum.UserInputType.MouseButton1 then
  180. local x = (i.Position.X - bar.AbsolutePosition.X)/bar.AbsoluteSize.X
  181. local val = math.clamp(math.floor(min + (max-min)*x),min,max)
  182. fill.Size = UDim2.new((val-min)/(max-min),0,1,0)
  183. label.Text = text.." ("..val..")"
  184. if cb then cb(val) end
  185. end
  186. end)
  187. end
  188.  
  189. -- Button
  190. function tab:AddButton(text,cb)
  191. local btn = Instance.new("TextButton", page)
  192. btn.Size = UDim2.new(1,0,0,ROW_HEIGHT)
  193. btn.BackgroundColor3 = Color3.fromRGB(70,70,95)
  194. btn.Text = text
  195. btn.Font = Enum.Font.GothamSemibold
  196. btn.TextSize = 14
  197. btn.TextColor3 = Color3.new(1,1,1)
  198. btn.AutoButtonColor = false
  199. btn.MouseButton1Click:Connect(function()
  200. if cb then cb() end
  201. end)
  202. end
  203.  
  204. -- Input
  205. function tab:AddInput(text,placeholder,cb)
  206. local box = Instance.new("TextBox", page)
  207. box.Size = UDim2.new(1,0,0,ROW_HEIGHT)
  208. box.BackgroundColor3 = Color3.fromRGB(45,45,60)
  209. box.PlaceholderText = placeholder
  210. box.Text = ""
  211. box.Font = Enum.Font.Gotham
  212. box.TextSize = 14
  213. box.TextColor3 = Color3.fromRGB(230,230,240)
  214. box.FocusLost:Connect(function()
  215. if cb then cb(box.Text) end
  216. end)
  217. end
  218.  
  219. -- Dropdown
  220. function tab:AddDropdown(text,options,default,cb)
  221. local holder = Instance.new("Frame", page)
  222. holder.Size = UDim2.new(1,0,0,ROW_HEIGHT)
  223. holder.ClipsDescendants = true
  224. holder.BackgroundTransparency = 1
  225.  
  226. local current = default or options[1]
  227. local open = false
  228.  
  229. local main = Instance.new("TextButton", holder)
  230. main.Size = UDim2.new(1,0,0,ROW_HEIGHT)
  231. main.BackgroundColor3 = Color3.fromRGB(45,45,65)
  232. main.Text = text..": "..current
  233. main.Font = Enum.Font.Gotham
  234. main.TextSize = 14
  235. main.TextColor3 = Color3.fromRGB(230,230,240)
  236. main.AutoButtonColor = false
  237.  
  238. local list = Instance.new("Frame", holder)
  239. list.Position = UDim2.new(0,0,0,ROW_HEIGHT)
  240. list.BackgroundColor3 = Color3.fromRGB(40,40,55)
  241. list.Size = UDim2.new(1,0,0,#options*28)
  242. list.Visible = false
  243.  
  244. local lay = Instance.new("UIListLayout", list)
  245.  
  246. for _,opt in ipairs(options) do
  247. local o = Instance.new("TextButton", list)
  248. o.Size = UDim2.new(1,0,0,28)
  249. o.Text = opt
  250. o.Font = Enum.Font.Gotham
  251. o.TextSize = 13
  252. o.TextColor3 = Color3.fromRGB(220,220,235)
  253. o.BackgroundTransparency = 1
  254. o.MouseButton1Click:Connect(function()
  255. current = opt
  256. main.Text = text..": "..opt
  257. list.Visible = false
  258. holder.Size = UDim2.new(1,0,0,ROW_HEIGHT)
  259. open = false
  260. if cb then cb(opt) end
  261. end)
  262. end
  263.  
  264. main.MouseButton1Click:Connect(function()
  265. open = not open
  266. list.Visible = open
  267. holder.Size = open
  268. and UDim2.new(1,0,0,ROW_HEIGHT + (#options*28))
  269. or UDim2.new(1,0,0,ROW_HEIGHT)
  270. end)
  271. end
  272.  
  273. return tab
  274. end
  275.  
  276. return Lib
  277.  
Advertisement
Add Comment
Please, Sign In to add comment