-
Notifications
You must be signed in to change notification settings - Fork 0
/
jgui.lua
155 lines (127 loc) · 4.73 KB
/
jgui.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
local UILibrary = {}
-- Function to create a basic UI container
function UILibrary:CreateUI(title)
local ScreenGui = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local Title = Instance.new("TextLabel")
local UICorner = Instance.new("UICorner")
local UIStroke = Instance.new("UIStroke")
-- Screen GUI
ScreenGui.Name = "ModernUI"
ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
ScreenGui.ResetOnSpawn = false
-- Main Frame
Frame.Name = "MainFrame"
Frame.Parent = ScreenGui
Frame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
Frame.Position = UDim2.new(0.3, 0, 0.3, 0)
Frame.Size = UDim2.new(0, 450, 0, 350)
Frame.BorderSizePixel = 0
-- Rounded corners for the frame
UICorner.CornerRadius = UDim.new(0, 10)
UICorner.Parent = Frame
-- Stroke effect for the frame
UIStroke.Parent = Frame
UIStroke.Color = Color3.fromRGB(50, 50, 50)
UIStroke.Thickness = 2
-- Title Label
Title.Name = "Title"
Title.Parent = Frame
Title.BackgroundTransparency = 1
Title.Size = UDim2.new(1, 0, 0, 50)
Title.Font = Enum.Font.GothamBold
Title.Text = title
Title.TextColor3 = Color3.fromRGB(240, 240, 240)
Title.TextSize = 24
return Frame
end
-- Function to create a button
function UILibrary:CreateButton(parent, text, callback)
local Button = Instance.new("TextButton")
local UICorner = Instance.new("UICorner")
Button.Parent = parent
Button.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
Button.Size = UDim2.new(0, 200, 0, 50)
Button.Font = Enum.Font.Gotham
Button.Text = text
Button.TextColor3 = Color3.fromRGB(255, 255, 255)
Button.TextSize = 16
Button.BorderSizePixel = 0
-- Rounded corners for the button
UICorner.CornerRadius = UDim.new(0, 8)
UICorner.Parent = Button
-- Button effects
Button.MouseEnter:Connect(function()
Button.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
end)
Button.MouseLeave:Connect(function()
Button.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
end)
Button.MouseButton1Click:Connect(callback)
return Button
end
-- Function to create a slider
function UILibrary:CreateSlider(parent, min, max, callback)
local SliderFrame = Instance.new("Frame")
local SliderBar = Instance.new("Frame")
local SliderKnob = Instance.new("Frame")
local UICorner = Instance.new("UICorner")
SliderFrame.Parent = parent
SliderFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
SliderFrame.Size = UDim2.new(0, 300, 0, 40)
SliderFrame.BorderSizePixel = 0
-- Rounded corners for the slider
UICorner.CornerRadius = UDim.new(0, 8)
UICorner.Parent = SliderFrame
SliderBar.Parent = SliderFrame
SliderBar.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
SliderBar.Size = UDim2.new(1, -20, 0.3, 0)
SliderBar.Position = UDim2.new(0.05, 0, 0.35, 0)
SliderKnob.Parent = SliderBar
SliderKnob.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
SliderKnob.Size = UDim2.new(0, 20, 1, 0)
SliderKnob.BorderSizePixel = 0
SliderKnob.Position = UDim2.new(0, 0, 0, 0)
-- Slider functionality
local dragging = false
SliderKnob.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = true
end
end)
SliderKnob.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = false
end
end)
SliderKnob:GetPropertyChangedSignal("Position"):Connect(function()
local value = math.clamp((SliderKnob.Position.X.Scale * max), min, max)
callback(value)
end)
return SliderFrame
end
-- Function to create a textbox
function UILibrary:CreateTextbox(parent, placeholder, callback)
local Textbox = Instance.new("TextBox")
local UICorner = Instance.new("UICorner")
Textbox.Parent = parent
Textbox.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
Textbox.Size = UDim2.new(0, 300, 0, 40)
Textbox.Font = Enum.Font.Gotham
Textbox.Text = ""
Textbox.PlaceholderText = placeholder
Textbox.PlaceholderColor3 = Color3.fromRGB(180, 180, 180)
Textbox.TextColor3 = Color3.fromRGB(255, 255, 255)
Textbox.TextSize = 16
Textbox.BorderSizePixel = 0
-- Rounded corners for the textbox
UICorner.CornerRadius = UDim.new(0, 8)
UICorner.Parent = Textbox
Textbox.FocusLost:Connect(function(enterPressed)
if enterPressed then
callback(Textbox.Text)
end
end)
return Textbox
end
return UILibrary