Add Library/MyUiLib

This commit is contained in:
Apapapa 2025-02-12 12:19:23 +00:00
parent 83de91fe82
commit bacbf3c628

514
Library/MyUiLib Normal file
View File

@ -0,0 +1,514 @@
local Library = {} -- Struktur dasar seperti yang Anda kirimkan
--------------------------------------------------
-- SERVICE
--------------------------------------------------
local RunService = game:GetService("RunService")
local LocalPlayer = game:GetService("Players").LocalPlayer
local Mouse = LocalPlayer:GetMouse()
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local TweenInfo = TweenInfo.new
--------------------------------------------------
-- INIT
--------------------------------------------------
local LocalizationService = game:GetService("LocalizationService")
local http = game:GetService("HttpService")
local NameID = LocalPlayer.Name
local GameName = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId).Name
local utility = {}
local Objects = {}
-- Fungsi Tween sederhana
function utility:Tween(instance, properties, duration, ...)
TweenService:Create(instance, TweenInfo(duration, ...), properties):Play()
end
-- Fitur save toggle (contoh awal konfigurasi)
local SettingToggle = {}
local Name = "BTConfig.JSON"
pcall(function()
if not pcall(function() readfile(Name) end) then
writefile(Name, game:GetService("HttpService"):JSONEncode(SettingToggle))
end
Settings = game:GetService("HttpService"):JSONEncode(readfile(Name))
end)
local LibName = tostring(math.random(1, 100))..tostring(math.random(1,50))..tostring(math.random(1, 100))
--------------------------------------------------
-- FUNGSI TOGGLE UI & DESTROY GUI
--------------------------------------------------
function Library:ToggleUI()
local gui = game.CoreGui:FindFirstChild(LibName)
if gui then
gui.Enabled = not gui.Enabled
end
end
function Library:DestroyGui()
local gui = game.CoreGui:FindFirstChild(LibName)
if gui then
gui:Destroy()
end
end
--------------------------------------------------
-- FUNGSI PEMBUATAN WINDOW (UI)
--------------------------------------------------
function Library:CreateWindow(hubname)
-- Masukkan nama window ke dalam Library (sebagai referensi)
table.insert(Library, hubname)
for i, v in pairs(game.CoreGui:GetChildren()) do
if v:IsA("ScreenGui") and v.Name == hubname then
v:Destroy()
end
end
-- Buat loading screen terlebih dahulu
local function createLoadingScreen()
local sg = Instance.new("ScreenGui")
sg.Name = "LoadingScreen"
sg.ResetOnSpawn = false
sg.Parent = game.CoreGui
local frame = Instance.new("Frame", sg)
frame.Name = "LoadingFrame"
frame.Size = UDim2.new(1, 0, 1, 0)
frame.BackgroundColor3 = Color3.new(0, 0, 0)
frame.BackgroundTransparency = 0.5
local spinner = Instance.new("ImageLabel", frame)
spinner.Name = "Spinner"
spinner.Size = UDim2.new(0, 100, 0, 100)
spinner.AnchorPoint = Vector2.new(0.5, 0.5)
spinner.Position = UDim2.new(0.5, 0, 0.5, 0)
spinner.Image = "rbxassetid://6034818372" -- Ganti dengan asset spinner pilihan Anda
spinner.BackgroundTransparency = 1
delay(2, function()
utility:Tween(frame, {BackgroundTransparency = 1}, 1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
wait(1)
sg:Destroy()
end)
end
createLoadingScreen()
-- Buat ScreenGui utama
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = LibName
ScreenGui.Parent = game.CoreGui
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Global
-- Toggle UI dengan CTRL
UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftControl then
Library:ToggleUI()
end
end)
-- Buat Body window
local Body = Instance.new("Frame")
Body.Name = "Body"
Body.Parent = ScreenGui
Body.BackgroundColor3 = Color3.fromRGB(12, 12, 12)
Body.BorderColor3 = Color3.fromRGB(0, 0, 0)
Body.BorderSizePixel = 0
Body.Position = UDim2.new(0.258, 0, 0.218, 0)
Body.Size = UDim2.new(0, 600, 0, 350)
Body.ClipsDescendants = true
local Body_Corner = Instance.new("UICorner")
Body_Corner.CornerRadius = UDim.new(0, 5)
Body_Corner.Name = "Body_Corner"
Body_Corner.Parent = Body
local Title_Hub = Instance.new("TextLabel")
Title_Hub.Name = "Title_Hub"
Title_Hub.Parent = Body
Title_Hub.BackgroundTransparency = 1
Title_Hub.Position = UDim2.new(0, 5, 0, 0)
Title_Hub.Size = UDim2.new(0, 558, 0, 30)
Title_Hub.Font = Enum.Font.SourceSansBold
Title_Hub.Text = hubname .. " - " .. GameName
Title_Hub.TextColor3 = Color3.fromRGB(255, 255, 255)
Title_Hub.TextSize = 15
Title_Hub.TextXAlignment = Enum.TextXAlignment.Left
-- Tombol minimize
local MInimize_Button = Instance.new("TextButton")
MInimize_Button.Name = "MInimize_Button"
MInimize_Button.Parent = Body
MInimize_Button.BackgroundTransparency = 1
MInimize_Button.Position = UDim2.new(0, 570, 0, 0)
MInimize_Button.Rotation = -315
MInimize_Button.Size = UDim2.new(0, 30, 0, 30)
MInimize_Button.AutoButtonColor = false
MInimize_Button.Font = Enum.Font.SourceSans
MInimize_Button.Text = "+"
MInimize_Button.TextColor3 = Color3.fromRGB(255, 255, 255)
MInimize_Button.TextSize = 40
MInimize_Button.MouseButton1Click:Connect(function()
if Body.Visible then
utility:Tween(Body, {Size = UDim2.new(0, 600, 0, 32)}, 0.3)
utility:Tween(MInimize_Button, {Rotation = 360}, 0.3)
Body.Visible = false
else
utility:Tween(Body, {Size = UDim2.new(0, 600, 0, 350)}, 0.3)
utility:Tween(MInimize_Button, {Rotation = -315}, 0.3)
Body.Visible = true
end
end)
-- Dynamic border effect pada window
startDynamicBorder(Body)
-- (Kode elemen Discord, waktu server, dsb., dihilangkan untuk fokus ke struktur utama)
--------------------------------------------------
-- PEMBUATAN TAB, SECTION, & MENU
--------------------------------------------------
-- Container untuk tombol tab (bagian atas Body)
local TabButtons = Instance.new("Frame", Body)
TabButtons.Name = "TabButtons"
TabButtons.Size = UDim2.new(1, 0, 0, 30)
TabButtons.Position = UDim2.new(0, 0, 0, 30)
TabButtons.BackgroundTransparency = 1
local btnLayout = Instance.new("UIListLayout", TabButtons)
btnLayout.FillDirection = Enum.FillDirection.Horizontal
btnLayout.HorizontalAlignment = Enum.HorizontalAlignment.Left
btnLayout.SortOrder = Enum.SortOrder.LayoutOrder
btnLayout.Padding = UDim.new(0, 5)
-- Container untuk konten tab
local TabContent = Instance.new("Frame", Body)
TabContent.Name = "TabContent"
TabContent.Size = UDim2.new(1, 0, 1, -60)
TabContent.Position = UDim2.new(0, 0, 0, 60)
TabContent.BackgroundTransparency = 1
local WindowObject = {}
-- Fungsi untuk mengatur ukuran window (UI)
function WindowObject:SetUISize(mode)
local s = sizes[mode]
if s then
tween(Body, {Size = UDim2.new(0, s.width, 0, s.height)}, 0.3)
else
warn("Invalid size mode. Use 'small', 'medium', or 'large'.")
end
end
-- Fungsi untuk membuat tab baru; opsi: Name, Icon, PremiumOnly (opsional)
function WindowObject:MakeTab(options)
options = options or {}
local tabName = options.Name or "Tab"
local tabButton = Instance.new("TextButton", TabButtons)
tabButton.Name = "TabButton_" .. tabName
tabButton.Size = UDim2.new(0, 100, 0, 30)
tabButton.BackgroundColor3 = Color3.fromRGB(50,50,50)
tabButton.Text = tabName
tabButton.Font = Enum.Font.SourceSans
tabButton.TextSize = 16
tabButton.TextColor3 = Color3.new(1,1,1)
local contentFrame = Instance.new("Frame", TabContent)
contentFrame.Name = "TabContent_" .. tabName
contentFrame.Size = UDim2.new(1, 0, 1, 0)
contentFrame.Position = UDim2.new(0, 0, 0, 0)
contentFrame.BackgroundTransparency = 1
contentFrame.Visible = false
tabButton.MouseButton1Click:Connect(function()
for _, v in ipairs(TabContent:GetChildren()) do
if v:IsA("Frame") then
v.Visible = false
end
end
contentFrame.Visible = true
end)
-- TabObject: Fungsi untuk menambahkan section ke dalam tab
local TabObject = {}
function TabObject:AddSection(options)
options = options or {}
local sectionName = options.Name or "Section"
local sectionFrame = Instance.new("Frame", contentFrame)
sectionFrame.Name = "Section_" .. sectionName
sectionFrame.Size = UDim2.new(1, -10, 0, 150)
sectionFrame.Position = UDim2.new(0, 5, 0, 5)
sectionFrame.BackgroundColor3 = Color3.fromRGB(30,30,30)
sectionFrame.BorderSizePixel = 0
local sectionHeader = Instance.new("TextLabel", sectionFrame)
sectionHeader.Name = "SectionHeader"
sectionHeader.Size = UDim2.new(1, 0, 0, 25)
sectionHeader.BackgroundTransparency = 1
sectionHeader.Text = sectionName
sectionHeader.Font = Enum.Font.SourceSansBold
sectionHeader.TextSize = 18
sectionHeader.TextColor3 = Color3.new(1,1,1)
sectionHeader.TextXAlignment = Enum.TextXAlignment.Left
local elementContainer = Instance.new("Frame", sectionFrame)
elementContainer.Name = "ElementContainer"
elementContainer.Size = UDim2.new(1, 0, 1, -25)
elementContainer.Position = UDim2.new(0, 0, 0, 25)
elementContainer.BackgroundTransparency = 1
local layout = Instance.new("UIListLayout", elementContainer)
layout.SortOrder = Enum.SortOrder.LayoutOrder
layout.Padding = UDim.new(0, 5)
local SectionObject = {}
-- addButton(title, callback)
function SectionObject:addButton(title, callback)
callback = callback or function() end
local btn = Instance.new("TextButton", elementContainer)
btn.Size = UDim2.new(1, -10, 0, 30)
btn.BackgroundColor3 = Color3.fromRGB(50,50,50)
btn.Text = title
btn.Font = Enum.Font.SourceSans
btn.TextSize = 16
btn.TextColor3 = Color3.new(1,1,1)
btn.MouseButton1Click:Connect(callback)
end
-- addToggle(title, default, callback)
function SectionObject:addToggle(title, default, callback)
callback = callback or function() end
local toggleFrame = Instance.new("Frame", elementContainer)
toggleFrame.Size = UDim2.new(1, -10, 0, 30)
toggleFrame.BackgroundColor3 = Color3.fromRGB(50,50,50)
local label = Instance.new("TextLabel", toggleFrame)
label.Size = UDim2.new(0.7, 0, 1, 0)
label.BackgroundTransparency = 1
label.Text = title
label.Font = Enum.Font.SourceSans
label.TextSize = 16
label.TextColor3 = Color3.new(1,1,1)
label.TextXAlignment = Enum.TextXAlignment.Left
local toggleButton = Instance.new("TextButton", toggleFrame)
toggleButton.Size = UDim2.new(0.3, 0, 1, 0)
toggleButton.Position = UDim2.new(0.7, 0, 0, 0)
toggleButton.BackgroundColor3 = default and Color3.fromRGB(0,255,0) or Color3.fromRGB(255,0,0)
toggleButton.Text = default and "ON" or "OFF"
toggleButton.Font = Enum.Font.SourceSansBold
toggleButton.TextSize = 16
toggleButton.TextColor3 = Color3.new(1,1,1)
toggleButton.MouseButton1Click:Connect(function()
default = not default
toggleButton.BackgroundColor3 = default and Color3.fromRGB(0,255,0) or Color3.fromRGB(255,0,0)
toggleButton.Text = default and "ON" or "OFF"
callback(default)
end)
end
-- addDropdown(title, default, list, callback)
function SectionObject:addDropdown(title, default, list, callback)
callback = callback or function() end
local dropdownFrame = Instance.new("Frame", elementContainer)
dropdownFrame.Size = UDim2.new(1, -10, 0, 30)
dropdownFrame.BackgroundColor3 = Color3.fromRGB(50,50,50)
local label = Instance.new("TextLabel", dropdownFrame)
label.Size = UDim2.new(0.7, 0, 1, 0)
label.BackgroundTransparency = 1
label.Text = title .. " : " .. default
label.Font = Enum.Font.SourceSans
label.TextSize = 16
label.TextColor3 = Color3.new(1,1,1)
label.TextXAlignment = Enum.TextXAlignment.Left
local dropdownButton = Instance.new("TextButton", dropdownFrame)
dropdownButton.Size = UDim2.new(0.3, 0, 1, 0)
dropdownButton.Position = UDim2.new(0.7, 0, 0, 0)
dropdownButton.BackgroundColor3 = Color3.fromRGB(70,70,70)
dropdownButton.Text = "v"
dropdownButton.Font = Enum.Font.SourceSansBold
dropdownButton.TextSize = 16
dropdownButton.TextColor3 = Color3.new(1,1,1)
local optionsContainer = Instance.new("Frame", dropdownFrame)
optionsContainer.Size = UDim2.new(1, 0, 0, #list * 30)
optionsContainer.Position = UDim2.new(0, 0, 1, 0)
optionsContainer.BackgroundColor3 = Color3.fromRGB(50,50,50)
optionsContainer.Visible = false
local optionsLayout = Instance.new("UIListLayout", optionsContainer)
optionsLayout.SortOrder = Enum.SortOrder.LayoutOrder
optionsLayout.Padding = UDim.new(0, 2)
for _, option in ipairs(list) do
local optionBtn = Instance.new("TextButton", optionsContainer)
optionBtn.Size = UDim2.new(1, 0, 0, 30)
optionBtn.BackgroundColor3 = Color3.fromRGB(60,60,60)
optionBtn.Text = option
optionBtn.Font = Enum.Font.SourceSans
optionBtn.TextSize = 16
optionBtn.TextColor3 = Color3.new(1,1,1)
optionBtn.MouseButton1Click:Connect(function()
label.Text = title .. " : " .. option
optionsContainer.Visible = false
callback(option)
end)
end
dropdownButton.MouseButton1Click:Connect(function()
optionsContainer.Visible = not optionsContainer.Visible
end)
end
-- addSlider(title, min, max, default, callback)
function SectionObject:addSlider(title, min, max, default, callback)
callback = callback or function() end
local sliderFrame = Instance.new("Frame", elementContainer)
sliderFrame.Size = UDim2.new(1, -10, 0, 40)
sliderFrame.BackgroundColor3 = Color3.fromRGB(50,50,50)
local label = Instance.new("TextLabel", sliderFrame)
label.Size = UDim2.new(0, 150, 1, 0)
label.BackgroundTransparency = 1
label.Text = title .. " : " .. tostring(default)
label.Font = Enum.Font.SourceSans
label.TextSize = 16
label.TextColor3 = Color3.new(1,1,1)
label.TextXAlignment = Enum.TextXAlignment.Left
local sliderTrack = Instance.new("Frame", sliderFrame)
sliderTrack.Size = UDim2.new(1, -160, 0, 10)
sliderTrack.Position = UDim2.new(0, 160, 0.5, -5)
sliderTrack.BackgroundColor3 = Color3.fromRGB(80,80,80)
local sliderKnob = Instance.new("Frame", sliderTrack)
sliderKnob.Size = UDim2.new(0, 10, 1, 0)
local knobX = (default - min) / (max - min)
sliderKnob.Position = UDim2.new(knobX, -5, 0, 0)
sliderKnob.BackgroundColor3 = Color3.fromRGB(255,0,0)
local dragging = false
sliderKnob.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = true
end
end)
sliderKnob.InputChanged:Connect(function(input)
if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
local relX = math.clamp(input.Position.X - sliderTrack.AbsolutePosition.X, 0, sliderTrack.AbsoluteSize.X)
local newVal = min + ((max - min) * (relX / sliderTrack.AbsoluteSize.X))
sliderKnob.Position = UDim2.new(relX / sliderTrack.AbsoluteSize.X, -5, 0, 0)
label.Text = title .. " : " .. string.format("%.2f", newVal)
callback(newVal)
end
end)
sliderKnob.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = false
end
end)
end
-- addKeybind(title, preset, callback)
function SectionObject:addKeybind(title, preset, callback)
callback = callback or function() end
local keybindFrame = Instance.new("Frame", elementContainer)
keybindFrame.Size = UDim2.new(1, -10, 0, 30)
keybindFrame.BackgroundColor3 = Color3.fromRGB(50,50,50)
local label = Instance.new("TextLabel", keybindFrame)
label.Size = UDim2.new(0, 150, 1, 0)
label.BackgroundTransparency = 1
label.Text = title
label.Font = Enum.Font.SourceSans
label.TextSize = 16
label.TextColor3 = Color3.new(1,1,1)
label.TextXAlignment = Enum.TextXAlignment.Left
local bindButton = Instance.new("TextButton", keybindFrame)
bindButton.Size = UDim2.new(0, 100, 1, 0)
bindButton.Position = UDim2.new(0, 160, 0, 0)
bindButton.BackgroundColor3 = Color3.fromRGB(70,70,70)
bindButton.Text = preset.Name
bindButton.Font = Enum.Font.SourceSansBold
bindButton.TextSize = 16
bindButton.TextColor3 = Color3.new(1,1,1)
bindButton.MouseButton1Click:Connect(function()
bindButton.Text = "..."
local input = UserInputService.InputBegan:Wait()
if input and input.KeyCode then
bindButton.Text = input.KeyCode.Name
callback(input.KeyCode.Name)
end
end)
end
-- addLabel(text)
function SectionObject:addLabel(text)
local lbl = Instance.new("TextLabel", elementContainer)
lbl.Size = UDim2.new(1, -10, 0, 20)
lbl.BackgroundTransparency = 1
lbl.Text = text
lbl.Font = Enum.Font.SourceSans
lbl.TextSize = 16
lbl.TextColor3 = Color3.new(1,1,1)
lbl.TextXAlignment = Enum.TextXAlignment.Left
end
-- addChangelog(text)
function SectionObject:addChangelog(text)
local lbl = Instance.new("TextLabel", elementContainer)
lbl.Size = UDim2.new(1, -10, 0, 20)
lbl.BackgroundTransparency = 1
lbl.Text = text
lbl.Font = Enum.Font.SourceSans
lbl.TextSize = 16
lbl.TextColor3 = Color3.fromRGB(85,170,255)
lbl.TextXAlignment = Enum.TextXAlignment.Left
end
-- addLog(text)
function SectionObject:addLog(text)
local lbl = Instance.new("TextLabel", elementContainer)
lbl.Size = UDim2.new(1, -10, 0, 20)
lbl.BackgroundTransparency = 1
lbl.Text = text
lbl.Font = Enum.Font.SourceSans
lbl.TextSize = 16
lbl.TextColor3 = Color3.fromRGB(255,255,0)
lbl.TextXAlignment = Enum.TextXAlignment.Left
end
return SectionObject
end
return TabObject
end
-- Jika MakeTab atau AddSection dipanggil langsung dari Library, munculkan error.
function Library:MakeTab(options)
error("MakeTab harus dipanggil dari objek window. Gunakan Window:MakeTab(options).")
end
function Library:AddSection(options)
error("AddSection harus dipanggil dari objek tab. Gunakan Tab:AddSection(options).")
end
-- WindowObject juga memiliki fungsi untuk notifikasi.
function WindowObject:MakeNotification(options)
Library:MakeNotification(options)
end
return WindowObject
end
--------------------------------------------------
-- RETURN LIBRARY
--------------------------------------------------
return Library