· 5 years ago · Feb 18, 2020, 04:52 PM
1--[[
2 ModMenu Lib DOCS
3
4 Settings
5 > Theme
6 > Main: COLOR3, defaults Color3.fromRGB(165, 96, 97)
7 > Background: COLOR3, defaults Color3.fromRGB(0, 0, 0)
8 > TextColor: COLOR3, defaults Color3.fromRGB(255, 255, 255)
9 > WindowCount: Amount of windows
10 > Draggable: BOOLEAN, whether the windows can be dragged or not
11 > Keybind: Enum.KeyCode, used to toggle UI
12
13 CreateMenu [params 1; settings]
14 > Menu: ScreenGui
15 > MenuSettings: Current settings for menu, refer to [Settings]
16 > MenuOptions
17 > CreateWindow [params 1, name]: Creates a new window, returns [Create Menu > MenuOptions > CreateWindow > WindowOptions]
18 > WindowOptions
19 > Toggles [table]: Currently enabled toggleables
20 > Add [params 2, type, name]: Creates a new child under window, returns [Create Menu > MenuOptions > CreateWindow > WindowOptions > Add > ButtonOptions]
21 > Name: Name of button
22 > Style: Current style of button [toggleable, clickable]
23 > Callback: Function called when button is clicked or toggled
24
25 Callbacks [custom params]
26 -> Default callback
27 function(Type, Name, a)
28 if Type == 'toggle' then
29 print(Name..' is now toggled to; '..tostring(a))
30 elseif Type == 'clickable' then
31 print(Name..' was clicked')
32 end
33 end
34 > Callbacks can be modified via [Create Menu > MenuOptions > CreateWindow > WindowOptions > Add > ButtonOptions > Callback]
35
36
37 Contact Information
38 > [DISCORD] Josh#0903
39
40 To Note:
41 > Draggable is buggy, don't ask me to fix that -> Do it yourself if you need a working one
42
43 Example Script:
44 > https://hastebin.com/jakibotohi.lua
45--]]
46
47local ModMenu = {}
48local ModMenuDefaultSettings = {
49 ['Theme'] = {
50 ['Main'] = Color3.fromRGB(171, 71, 188),
51 ['Background'] = Color3.fromRGB(0, 0, 0),
52 ['TextColor'] = Color3.fromRGB(255, 255, 255)
53 },
54 ['WindowCount'] = -1,
55 ['Draggable'] = true,
56 ['Keybind'] = Enum.KeyCode.F2
57} -- Settings for UIs without [param [Settings]]
58
59ModMenu.CreateMenu = function(Settings)
60 if game:GetService'CoreGui':FindFirstChild'ModMenu' then
61 error'ModMenu Lib: Menu already exists'
62 return
63 end
64 local Menu = Instance.new'ScreenGui'
65 Menu.Name = 'ModMenu'
66 Menu.Parent = game:GetService'CoreGui'
67 local RFrameGuis = {}
68 local RTextLabels = {}
69 local TKeys = {}
70 local TGetKey = false
71 local TGrabKey
72 local CurrentColor = Color3.new()
73 local function TableFind(tab,el)
74 for index, value in pairs(tab) do
75 if value == el then
76 return index
77 end
78 end
79 end
80 local MenuSettings = ModMenuDefaultSettings
81 if Settings then
82 MenuSettings = Settings
83 end
84 local UpdateCallback = function() end
85 local MenuOptions = {}
86 local GlobalModules = {}
87 local GlobalEmuModules = {}
88 local GlobalEmuKeyBindModules = {}
89 local AllowDrag = {}
90
91 MenuOptions.CreateWindow = function(Name)
92 if not Menu:FindFirstChild'Windows' then
93 local Windows = Instance.new'Frame'
94 Windows.Name = "Windows"
95 Windows.Parent = Menu
96 Windows.BackgroundTransparency = 1
97 Windows.Position = UDim2.new(0, 10, 0, 70)
98 Windows.Size = UDim2.new(1, -20, 0, 0)
99 end
100 if Name == 'Windows' then
101 error'ModMenu Lib: Name not allowed'
102 return
103 end
104
105 local LastPos = -1
106 for _, v in next, Menu.Windows:GetChildren() do
107 if v.Size.X.Offset > LastPos then
108 LastPos = v.Position.X.Offset
109 end
110 end
111
112 local NewWindow = Instance.new'Frame'
113 local Title = Instance.new'TextLabel'
114 local Title_2 = Instance.new'TextLabel'
115 local Children = Instance.new'Frame'
116
117 local UIS = game:GetService("UserInputService")
118 local dragging
119 local dragInput
120 local dragStart
121 local startPos
122
123 local function update(input)
124 local delta = input.Position - dragStart
125 NewWindow.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
126 end
127
128 NewWindow.InputBegan:Connect(function(input)
129 if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
130 dragging = true
131 dragStart = input.Position
132 startPos = NewWindow.Position
133
134 input.Changed:Connect(function()
135 if input.UserInputState == Enum.UserInputState.End then
136 dragging = false
137 end
138 end)
139 end
140 end)
141
142 NewWindow.InputChanged:Connect(function(input)
143 if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
144 dragInput = input
145 end
146 end)
147
148 UIS.InputChanged:Connect(function(input)
149 if input == dragInput and dragging then
150 update(input)
151 end
152 end)
153
154 NewWindow.Name = Name
155 NewWindow.Parent = Menu:WaitForChild'Windows'
156 NewWindow.BackgroundColor3 = MenuSettings.Theme.Main
157 table.insert(RFrameGuis, NewWindow)
158 NewWindow.BorderSizePixel = 0
159 NewWindow.Size = UDim2.new(0, 150, 0, 25)
160 NewWindow.Active = true
161
162 Title.Name = "Title"
163 Title.Parent = NewWindow
164 Title.BackgroundColor3 = Color3.new(1, 1, 1)
165 Title.BackgroundTransparency = 1
166 Title.Size = UDim2.new(1, 0, 0.9, 0)
167 Title.ZIndex = 3
168 Title.Font = Enum.Font.SourceSans
169 Title.Text = Name
170 Title.TextColor3 = Color3.new(1, 1, 1)
171 Title.TextSize = 17
172
173 Title_2.Name = "bg"
174 Title_2.Parent = Title
175 Title_2.BackgroundColor3 = Color3.new(1, 1, 1)
176 Title_2.BackgroundTransparency = 1
177 Title_2.Position = UDim2.new(0, 1, 0, 1)
178 Title_2.Size = UDim2.new(1, 0, 1, 0)
179 Title_2.Font = Enum.Font.SourceSans
180 Title_2.Text = Name
181 Title_2.TextSize = 17
182 Title_2.ZIndex = 2
183
184 Children.Name = "Children"
185 Children.Parent = NewWindow
186 Children.BackgroundColor3 = Color3.new(0, 0, 0)
187 Children.BackgroundTransparency = 0.5
188 Children.BorderSizePixel = 0
189 Children.Position = UDim2.new(0.015, 0, 1, 0)
190 Children.Size = UDim2.new(0.97, 0, 0, 0)
191
192 MenuSettings.WindowCount = MenuSettings.WindowCount + 1
193 if MenuSettings.WindowCount > 1 then
194 NewWindow.Position = UDim2.new(0, LastPos * MenuSettings.WindowCount, 0, 0)
195 elseif MenuSettings.WindowCount == 1 then
196 NewWindow.Position = UDim2.new(0, 155, 0, 0)
197 end
198
199 local WindowOptions = {}
200 WindowOptions.Toggles = {}
201
202 WindowOptions.Add = function(Type, Name)
203 Type = string.lower(Type)
204 if not NewWindow:FindFirstChild'Children' then
205 error'ModMenu Lib: Children container not existent'
206 return
207 end
208 Children.Size = UDim2.new(0.97, 0, Children.Size.Y.Scale + 1, 0)
209 local LastPos = -1
210 for _, v in next, Children:GetChildren() do
211 if v.Size.Y.Offset > LastPos then
212 LastPos = v.Position.Y.Offset
213 end
214 end
215
216 local Frame = Instance.new'TextButton'
217 local TextLabel = Instance.new'TextLabel'
218 local toggled = Instance.new'TextLabel'
219 local tvar = false
220 Frame.Name = "Frame"
221 Frame.Active = false
222 Frame.BackgroundTransparency = 1
223 Frame.BorderSizePixel = 0
224 Frame.Selectable = false
225 Frame.Size = UDim2.new(0, 146, 0, 25)
226 Frame.Text = ""
227 Frame.TextTransparency = 1
228
229 if LastPos == -1 then
230 Frame.Position = UDim2.new(0, 0, 0, 0)
231 else
232 Frame.Position = UDim2.new(0, 0, 0, #Children:GetChildren() * 25)
233 end
234
235 Frame.Parent = NewWindow.Children
236
237 TextLabel.Parent = Frame
238 TextLabel.BackgroundColor3 = Color3.new(1, 1, 1)
239 TextLabel.BackgroundTransparency = 1
240 TextLabel.Position = UDim2.new(0.2, 0, 0, 0)
241 TextLabel.Size = UDim2.new(0.8, 0, 0.9, 0)
242 TextLabel.Font = Enum.Font.SourceSansBold
243 TextLabel.Text = Name
244 TextLabel.TextColor3 = Color3.new(1, 1, 1)
245 TextLabel.TextSize = 14
246 TextLabel.TextXAlignment = Enum.TextXAlignment.Left
247
248 toggled.Name = "toggled"
249 toggled.Parent = Frame
250 toggled.BackgroundColor3 = Color3.new(1, 1, 1)
251 toggled.BackgroundTransparency = 1
252 toggled.Position = UDim2.new(0.075, 0, 0.03, 0)
253 toggled.Size = UDim2.new(0.1, 0, 0.9, 0)
254 toggled.Font = Enum.Font.SourceSansBold
255 toggled.Text = ">"
256 toggled.TextColor3 = MenuSettings.Theme.TextColor
257 toggled.TextSize = 20
258 toggled.TextXAlignment = Enum.TextXAlignment.Left
259 toggled.Visible = true
260
261 local ButtonOptions = {}
262 ButtonOptions.Name = Name
263 ButtonOptions.Style = Type
264
265 -- Default callback
266 ButtonOptions['Callback'] = function(Type, Name, a)
267 --Nothing
268 end
269
270 -- maybe add more themes later idk
271 if Type == 'toggle' then
272 GlobalEmuModules[Name] = (function()
273 GlobalModules[Name] = not tvar
274 WindowOptions.Toggles[Name] = not tvar
275 if WindowOptions.Toggles[Name] then
276 table.insert(RTextLabels, toggled)
277 else
278 table.remove(RTextLabels, TableFind(RTextLabels, toggled))
279 end
280 tvar = WindowOptions.Toggles[Name]
281 if WindowOptions.Toggles[Name] then
282 TextLabel.TextColor3 = CurrentColor
283 table.insert(RTextLabels, TextLabel)
284 else
285 TextLabel.TextColor3 = MenuSettings.Theme.TextColor
286 toggled.TextColor3 = MenuSettings.Theme.TextColor
287 table.remove(RTextLabels, TableFind(RTextLabels, TextLabel))
288 end
289 UpdateCallback(GlobalModules)
290 ButtonOptions['Callback'](Type, Name, WindowOptions.Toggles[Name])
291 end)
292 Frame.MouseButton1Click:connect(function()
293 GlobalModules[Name] = not tvar
294 WindowOptions.Toggles[Name] = not tvar
295 if WindowOptions.Toggles[Name] then
296 table.insert(RTextLabels, toggled)
297 else
298 table.remove(RTextLabels, TableFind(RTextLabels, toggled))
299 end
300 tvar = WindowOptions.Toggles[Name]
301 if WindowOptions.Toggles[Name] then
302 TextLabel.TextColor3 = CurrentColor
303 table.insert(RTextLabels, TextLabel)
304 else
305 TextLabel.TextColor3 = MenuSettings.Theme.TextColor
306 toggled.TextColor3 = MenuSettings.Theme.TextColor
307 table.remove(RTextLabels, TableFind(RTextLabels, TextLabel))
308 end
309 UpdateCallback(GlobalModules)
310 ButtonOptions['Callback'](Type, Name, WindowOptions.Toggles[Name])
311 end)
312 GlobalEmuKeyBindModules[Name] = (function(KeyCode)
313 TextLabel.Text = Name .. " [" .. KeyCode.Name .. "]"
314 TKeys[Name] =
315 {
316 Callback = function()
317 GlobalModules[Name] = not tvar
318 WindowOptions.Toggles[Name] = not tvar
319 if WindowOptions.Toggles[Name] then
320 table.insert(RTextLabels, toggled)
321 else
322 table.remove(RTextLabels, TableFind(RTextLabels, toggled))
323 end
324 tvar = WindowOptions.Toggles[Name]
325 if WindowOptions.Toggles[Name] then
326 TextLabel.TextColor3 = CurrentColor
327 table.insert(RTextLabels, TextLabel)
328 else
329 TextLabel.TextColor3 = MenuSettings.Theme.TextColor
330 toggled.TextColor3 = MenuSettings.Theme.TextColor
331 table.remove(RTextLabels, TableFind(RTextLabels, TextLabel))
332 end
333 UpdateCallback(GlobalModules)
334 ButtonOptions['Callback'](Type, Name, WindowOptions.Toggles[Name])
335 end,
336 Key = KeyCode
337 }
338 end)
339 Frame.MouseButton2Click:connect(function()
340 if TGetKey then
341 TKeys[Name] = nil
342 TextLabel.Text = Name
343 TGrabKey = true
344 TGetKey = false
345 return
346 end
347 TGetKey = true
348 TextLabel.Text = Name .. " [-]"
349 while not TGrabKey do wait() end
350 if TGrabKey == true then TGrabKey = nil TextLabel.Text = Name return end
351 TKeys[Name] =
352 {
353 Callback = function()
354 GlobalModules[Name] = not tvar
355 WindowOptions.Toggles[Name] = not tvar
356 if WindowOptions.Toggles[Name] then
357 table.insert(RTextLabels, toggled)
358 else
359 table.remove(RTextLabels, TableFind(RTextLabels, toggled))
360 end
361 tvar = WindowOptions.Toggles[Name]
362 if WindowOptions.Toggles[Name] then
363 TextLabel.TextColor3 = CurrentColor
364 table.insert(RTextLabels, TextLabel)
365 else
366 TextLabel.TextColor3 = MenuSettings.Theme.TextColor
367 toggled.TextColor3 = MenuSettings.Theme.TextColor
368 table.remove(RTextLabels, TableFind(RTextLabels, TextLabel))
369 end
370 UpdateCallback(GlobalModules)
371 ButtonOptions['Callback'](Type, Name, WindowOptions.Toggles[Name])
372 end,
373 Key = TGrabKey.KeyCode
374 }
375 TextLabel.Text = Name .. " [" .. TGrabKey.KeyCode.Name .. "]"
376 TGrabKey = nil
377 TGetKey = false
378 end)
379 elseif Type == 'clickable' then
380 Frame.MouseButton1Click:connect(function()
381 ButtonOptions['Callback'](Type, Name)
382 spawn(function()
383 toggled.TextColor3 = CurrentColor
384 TextLabel.TextColor3 = CurrentColor
385 table.insert(RTextLabels, toggled)
386 table.insert(RTextLabels, TextLabel)
387 wait(0.5)
388 toggled.TextColor3 = MenuSettings.Theme.TextColor
389 TextLabel.TextColor3 = MenuSettings.Theme.TextColor
390 table.remove(RTextLabels, TableFind(RTextLabels, toggled))
391 table.remove(RTextLabels, TableFind(RTextLabels, TextLabel))
392 end)
393 end)
394 GlobalEmuKeyBindModules[Name] = (function(KeyCode)
395 TextLabel.Text = Name .. " [" .. KeyCode.Name .. "]"
396 TKeys[Name] =
397 {
398 Callback = function()
399 ButtonOptions['Callback'](Type, Name)
400 spawn(function()
401 toggled.TextColor3 = CurrentColor
402 TextLabel.TextColor3 = CurrentColor
403 table.insert(RTextLabels, toggled)
404 table.insert(RTextLabels, TextLabel)
405 wait(0.5)
406 toggled.TextColor3 = MenuSettings.Theme.TextColor
407 TextLabel.TextColor3 = MenuSettings.Theme.TextColor
408 table.remove(RTextLabels, TableFind(RTextLabels, toggled))
409 table.remove(RTextLabels, TableFind(RTextLabels, TextLabel))
410 end)
411 end,
412 Key = KeyCode
413 }
414 end)
415 Frame.MouseButton2Click:connect(function()
416 if TGetKey then
417 TKeys[Name] = nil
418 TextLabel.Text = Name
419 TGrabKey = true
420 TGetKey = false
421 return
422 end
423 TGetKey = true
424 TextLabel.Text = Name .. " [-]"
425 while not TGrabKey do wait() end
426 if TGrabKey == true then TGrabKey = nil TextLabel.Text = Name return end
427 TKeys[Name] =
428 {
429 Callback = function()
430 ButtonOptions['Callback'](Type, Name)
431 spawn(function()
432 toggled.TextColor3 = CurrentColor
433 TextLabel.TextColor3 = CurrentColor
434 table.insert(RTextLabels, toggled)
435 table.insert(RTextLabels, TextLabel)
436 wait(0.5)
437 toggled.TextColor3 = MenuSettings.Theme.TextColor
438 TextLabel.TextColor3 = MenuSettings.Theme.TextColor
439 table.remove(RTextLabels, TableFind(RTextLabels, toggled))
440 table.remove(RTextLabels, TableFind(RTextLabels, TextLabel))
441 end)
442 end,
443 Key = TGrabKey.KeyCode
444 }
445 TextLabel.Text = Name .. " [" .. TGrabKey.KeyCode.Name .. "]"
446 TGrabKey = nil
447 TGetKey = false
448 end)
449 end
450
451 return ButtonOptions
452 end
453 return WindowOptions
454 end
455
456 local UserInputService = game:GetService'UserInputService'
457 local Enabled = true
458
459 local JBFrame = Instance.new("Frame")
460 local JBTextLabel = Instance.new("TextLabel")
461 local JBTextLabel_2 = Instance.new("TextLabel")
462
463 JBFrame.Parent = Menu
464 JBFrame.Active = true
465 JBFrame.BackgroundTransparency = 1
466 JBFrame.Position = UDim2.new(0, 2, 0, 2)
467 JBFrame.Size = UDim2.new(0, 380, 0, 80)
468
469 JBTextLabel.Parent = JBFrame
470 JBTextLabel.Active = true
471 JBTextLabel.TextStrokeTransparency = 0.75
472 JBTextLabel.BackgroundTransparency = 1
473 JBTextLabel.Position = UDim2.new(0, 10, 0, 0)
474 JBTextLabel.Size = UDim2.new(0, 210, 0, 60)
475 JBTextLabel.Font = Enum.Font.SourceSansLight
476 JBTextLabel.Text = "jailbreakhaxx"
477 JBTextLabel.TextSize = 48
478 JBTextLabel.TextXAlignment = Enum.TextXAlignment.Left
479 table.insert(RTextLabels, JBTextLabel)
480
481 JBTextLabel_2.Parent = JBFrame
482 JBTextLabel_2.Active = true
483 JBTextLabel_2.BackgroundTransparency = 1
484 JBTextLabel_2.TextStrokeTransparency = 0.75
485 JBTextLabel_2.BorderSizePixel = 0
486 JBTextLabel_2.Position = UDim2.new(0, 220, 0, 10)
487 JBTextLabel_2.Size = UDim2.new(0, 50, 0, 50)
488 JBTextLabel_2.Font = Enum.Font.SourceSansLight
489 JBTextLabel_2.Text = "v5.0-luau"
490 JBTextLabel_2.TextColor3 = Color3.new(0.501961, 0.501961, 0.501961)
491 JBTextLabel_2.TextSize = 24
492 JBTextLabel_2.TextXAlignment = Enum.TextXAlignment.Left
493 JBTextLabel_2.TextYAlignment = Enum.TextYAlignment.Bottom
494
495 UserInputService.InputBegan:connect(function(a, b)
496 if a.UserInputType == Enum.UserInputType.Keyboard then
497 if TGetKey then TGrabKey = a return end
498
499 for I,V in pairs(TKeys) do
500 if type(V) == "table" then
501 if V["Key"] == a.KeyCode then
502 V["Callback"]()
503 end
504 end
505 end
506
507 if a.KeyCode == MenuSettings.Keybind then
508 Menu.Enabled = not Enabled
509 Enabled = not Enabled
510 for I,V in pairs(AllowDrag) do
511 V.Draggable = Enabled
512 end
513 local StarterGui = game:GetService('StarterGui')
514 if Enabled then
515 StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
516 else
517 StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
518 end
519 end
520 end
521 end)
522
523 spawn(function()
524 while true do
525 for i = 0, 1, 0.01 do
526 if Enabled then
527 CurrentColor = Color3.fromHSV(i,1,1)
528 for i,v in pairs(RFrameGuis) do
529 v.BackgroundColor3 = CurrentColor
530 end
531 for i,v in pairs(RTextLabels) do
532 v.TextColor3 = CurrentColor
533 end
534 end
535 wait(0.1)
536 end
537 end
538 end)
539
540 function SetUpdateCallback(Call)
541 UpdateCallback = Call
542 end
543
544 function AddAllowDrag(Element)
545 table.insert(AllowDrag, Element)
546 end
547
548 function GetKeyBinds()
549 return TKeys
550 end
551
552 function GetActive()
553 return GlobalModules
554 end
555
556 function EmuToggle(Name)
557 GlobalEmuModules[Name]()
558 end
559
560 function EmuKeyBind(Name, KeyCode)
561 GlobalEmuKeyBindModules[Name](KeyCode)
562 end
563
564
565 return {
566 ['Menu'] = Menu,
567 ['MenuSettings'] = MenuSettings,
568 ['MenuOptions'] = MenuOptions,
569 ['SetUpdateCallback'] = SetUpdateCallback,
570 ['AddAllowDrag'] = AddAllowDrag,
571 ['GetKeyBinds'] = GetKeyBinds,
572 ['GetActive'] = GetActive,
573 ['EmulateToggle'] = EmuToggle,
574 ['EmulateKeyBind'] = EmuKeyBind,
575 }
576end
577
578return ModMenu