local library = {
windowcount = 0;
}
local defaults = {
txtcolor = Color3.fromRGB(255, 255, 255),
underline = Color3.fromRGB(0, 255, 140),
barcolor = Color3.fromRGB(40, 40, 40),
bgcolor = Color3.fromRGB(30, 30, 30),
}
function library:Create(class, props)
local object = Instance.new(class);
for i, prop in next, props do
if i ~= "Parent" then
object[i] = prop;
end
end
object.Parent = props.Parent;
return object;
end
function library:CreateWindow(options)
local window = {
count = 0;
toggles = {},
closed = false;
}
local options = options or {};
setmetatable(options, {__index = defaults})
self.windowcount = self.windowcount + 1;
if not library.gui then
library.gui = self:Create("ScreenGui", {Name = "UILibrary", Parent = game:GetService("CoreGui")})
end
window.frame = self:Create("Frame", {
Parent = self.gui,
Active = true,
Draggable = true,
BackgroundTransparency = 0,
Size = UDim2.new(0, 190, 0, 30),
Position = UDim2.new(0, (15 + ((200 * self.windowcount) - 200)), 0, 15),
BackgroundColor3 = options.barcolor,
BorderSizePixel = 0;
})
window.background = self:Create('Frame', {
Parent = window.frame,
BorderSizePixel = 0;
BackgroundColor3 = options.bgcolor,
Position = UDim2.new(0, 0, 1, 0),
Size = UDim2.new(1, 0, 0, 25),
ClipsDescendants = true;
})
self:Create("Frame", {
Size = UDim2.new(1, 0, 0, 1),
Position = UDim2.new(0, 0, 1, -1),
BorderSizePixel = 0;
BackgroundColor3 = options.underline;
Parent = window.frame
})
local togglebutton = self:Create("TextButton", {
ZIndex = 2,
BackgroundTransparency = 1;
Position = UDim2.new(1, -25, 0, 0),
Size = UDim2.new(0, 25, 1, 0),
Text = "-",
TextSize = 17,
TextColor3 = options.txtcolor,
Font = Enum.Font.SourceSans;
Parent = window.frame,
});
togglebutton.MouseButton1Click:connect(function()
window.closed = not window.closed
togglebutton.Text = (window.closed and "+" or "-")
if window.closed then
window:Resize(true, UDim2.new(1, 0, 0, 0))
else
window:Resize(true)
end
end)
self:Create("TextLabel", {
Size = UDim2.new(1, 0, 1, 0),
BackgroundTransparency = 1;
BorderSizePixel = 0;
TextColor3 = options.txtcolor,
TextColor3 = (options.bartextcolor or Color3.fromRGB(255, 255, 255));
TextSize = 17,
Font = Enum.Font.SourceSansSemibold;
Text = options.text or "window",
Name = "Window",
Parent = window.frame,
})
function window:Resize(tween, change)
local size = change or UDim2.new(1, 0, 0, ((20 * self.count) + 10))
if tween then
self.background:TweenSize(size, "Out", "Sine", 0.5, true)
else
self.background.Size = size
end
end
function window:AddToggle(text, callback)
self.count = self.count + 1
callback = callback or function() end
local label = library:Create("TextLabel", {
Text = text,
Size = UDim2.new(1, -10, 0, 20);
Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
BackgroundTransparency = 1;
TextColor3 = Color3.fromRGB(255, 255, 255);
TextXAlignment = Enum.TextXAlignment.Left;
TextSize = 16,
Font = Enum.Font.SourceSans,
Parent = self.background;
})
local button = library:Create("TextButton", {
Text = "OFF",
TextColor3 = Color3.fromRGB(255, 25, 25),
BackgroundTransparency = 1;
Position = UDim2.new(1, -25, 0, 0),
Size = UDim2.new(0, 25, 1, 0),
TextSize = 17,
Font = Enum.Font.SourceSansSemibold,
Parent = label;
})
button.MouseButton1Click:connect(function()
self.toggles[text] = (not self.toggles[text])
button.TextColor3 = (self.toggles[text] and Color3.fromRGB(0, 255, 140) or Color3.fromRGB(255, 25, 25))
button.Text =(self.toggles[text] and "ON" or "OFF")
callback(self.toggles[text])
end)
self:Resize()
return button
end
function window:AddBox(text, callback)
self.count = self.count + 1
callback = callback or function() end
local box = library:Create("TextBox", {
PlaceholderText = text,
Size = UDim2.new(1, -10, 0, 20);
Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
BackgroundTransparency = 0.75;
BackgroundColor3 = options.boxcolor,
TextColor3 = Color3.fromRGB(255, 255, 255);
TextXAlignment = Enum.TextXAlignment.Center;
TextSize = 16,
Text = "",
Font = Enum.Font.SourceSans,
BorderSizePixel = 0;
Parent = self.background;
})
box.FocusLost:connect(function(...)
callback(box, ...)
end)
self:Resize()
return box
end
function window:AddButton(text, callback)
self.count = self.count + 1
callback = callback or function() end
local button = library:Create("TextButton", {
Text = text,
Size = UDim2.new(1, -10, 0, 20);
Position = UDim2.new(0, 5, 0, ((20 * self.count) - 20) + 5),
BackgroundTransparency = 1;
TextColor3 = Color3.fromRGB(255, 255, 255);
TextXAlignment = Enum.TextXAlignment.Left;
TextSize = 16,
Font = Enum.Font.SourceSans,
Parent = self.background;
})
button.MouseButton1Click:connect(callback)
self:Resize()
return button
end
return window
end
return library