· 3 years ago · Jan 15, 2022, 12:20 AM
1LibraryV2 = {}
2LibraryV2.__index = LibraryV2
3LibraryV2.Notifications = {}
4
5--[[ // Plan
6
7 Program config checker
8 See if user has ever used the script before, else prompt first time UI
9
10 LIB SYSTEM - {
11
12 Tab creation - {
13
14 Tab (instance)
15 Name (string)
16 Containers (table)
17
18 }
19
20 Container creation - {
21
22 Container (instance)
23 Name (string)
24 Tab (table)
25 Assets (table)
26
27 }
28
29 Asset creation - {
30
31 Asset (instance)
32 Name (string)
33 Container (table)
34
35 Get (func) - {
36 arguments:
37 [1] = string (can get a certain piece of data about the asset if it's available eg. Toggle_State)
38 }
39
40 }
41
42 Show (global func)
43 Hide (global func) - Alliases {
44 arguments:
45 [1] = bool (hide all in same tab)
46 }.
47 Update (global func)
48 }
49
50--]]
51
52--// Services
53local TweenService = game:GetService("TweenService")
54local Players = game:GetService("Players")
55local Workspace = game:GetService("Workspace")
56
57-- Shortened funcs
58local u2 = UDim2.new
59local v3 = Vector3.new
60local pi = math.pi
61local hf = hookfunction
62
63-- Needed assets
64
65-- Outer blur
66local Blur = Instance.new("BlurEffect")
67Blur.Name = "Xenon_Blur"
68Blur.Size = 0
69Blur.Parent = game.Lighting
70
71
72-- Useful funcs
73
74function TandemTween(tbl, according, totaltime)
75
76 local time_per = (totaltime/#tbl)
77
78 for i = 1, #tbl do
79
80 Tween(according[i], {Position = tbl[i]}, time_per)
81 task.wait(time_per)
82
83 end
84
85end
86
87function Tween(inst, tType, t, yield, pref)
88 local Tween = TweenService:Create(inst, TweenInfo.new(pref and pref or t and t or 1), tType)
89 Tween:Play()
90
91 if yield then
92 Tween.Completed:Wait()
93 end
94end
95
96function RoundNumber(num, numDecimalPlaces)
97 return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
98end
99
100function Ripple(asset, x, y)
101 assert(x and y, "Please provide x and y coordinates!")
102
103 coroutine.resume(coroutine.create(function()
104 local New_Ripple = GetAsset("RippleAsset"):Clone()
105 New_Ripple.Parent = asset
106 New_Ripple.ImageTransparency = 0.6
107 New_Ripple.Position = u2(0, (x-asset.AbsolutePosition.X), 0, (y-asset.AbsolutePosition.Y-36))
108 New_Ripple.Size = u2(0, 0, 0, 0)
109
110 local Length, Size = 0.6, (asset.AbsoluteSize.X >= asset.AbsoluteSize.Y and asset.AbsoluteSize.X * 1.5 or button.AbsoluteSize.Y * 1.5)
111 local Tween = game:GetService("TweenService"):Create(New_Ripple, TweenInfo.new(Length, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
112 Size = u2(0, Size, 0, Size),
113 Position = u2(0.5, (-Size / 2), 0.5, (-Size / 2)),
114 ImageTransparency = 1
115 })
116 Tween:Play()
117 Tween.Completed:Wait()
118 New_Ripple:Destroy()
119 end))
120end
121
122function WaitUntil(wait_for)
123 repeat task.wait() until wait_for
124end
125
126function GetAsset(Asset)
127 for i,v in pairs(game.CoreGui:FindFirstChild("TUI2"):GetDescendants()) do
128 if v.Name == Asset then
129 return v
130 end
131 end
132end
133
134function LibraryV2.UI(Name)
135
136 if game.CoreGui:FindFirstChild("TUI2") then
137 game.CoreGui.TUI2:Destroy();
138 game.Lighting:FindFirstChild("Xenon_Blur"):Destroy();
139 end
140
141 local Library
142 Library = {
143 _UI = game:GetObjects("rbxassetid://8388979705")[1],
144 Name = Name or "Untitled",
145 Tabs = {},
146 State = false,
147 ToggleKey = Enum.KeyCode.LeftControl,
148 Debounce = false,
149
150 Show_UI = function()
151 local P = Library._UI.Lib.Position
152 Tween(Library._UI.Lib, {Position = u2(0.75, P.X.Offset, P.Y.Size, P.Y.Offset)})
153 end,
154
155 Hide_UI = function()
156 local P = Library.UI.Lib.Position
157 Tween(Library._UI.Lib, {Position = u2(1, P.X.Offset, P.Y.Size, P.Y.Offset)})
158 end,
159
160 Hide_All = function()
161 for i,v in pairs(Library._UI.Lib.Holder:GetChildren()) do
162 if v.ClassName ~= "UIListLayout" and v.ClassName ~= "Folder" then
163 v.Visible = false
164 end
165 end
166 end,
167
168 Show = function(show_tbl)
169 for i,v in pairs(show_tbl) do
170 v.Visible = true
171 end
172 end,
173
174 Hide = function(hide_tbl)
175 for i,v in pairs(hide_tbl) do
176 v.Visible = false
177 end
178 end,
179
180 Startup = function()
181 local TUI = Library._UI
182 local Widgets = TUI.Widgets
183 local Widget1, Widget2, Widget3, Widget4 = Widgets.Bookmarks, Widgets.Widget, Widgets.Discord, Widgets.Music
184 local Tabs = TUI.TabContainer
185 local BottomMenu = TUI.BottomMenu
186 local TopMenu = TUI.Top
187 local Time = TUI.Time
188 local TimeLabel = TUI.TimeLabel
189
190 local TabsPos = Tabs.Position
191 local BMPos = BottomMenu.Position
192 local TPos = TopMenu.Position
193 local TimePos = Time.Position
194 local TLPos = TimeLabel.Position
195 local Transparency_Back = TUI.Darkener.BackgroundTransparency
196 local Widgets = {Widget1, Widget2, Widget3, Widget4}
197 local WidgetPos = {
198
199 Widget1.Position,
200 Widget2.Position,
201 Widget3.Position,
202 Widget4.Position
203
204 }
205
206 for i,v in pairs(Widgets) do
207 v.Position = UDim2.new(v.Position.X.Scale, v.Position.X.Offset, 1, v.Position.Y.Offset)
208 end
209 Tabs.Position = UDim2.new(-0.05, Tabs.Position.X.Offset, Tabs.Position.Y.Scale, Tabs.Position.Y.Offset)
210 BottomMenu.Position = UDim2.new(BottomMenu.Position.X.Scale, BottomMenu.Position.X.Offset, 1, BottomMenu.Position.Y.Offset)
211 TopMenu.Position = UDim2.new(TopMenu.Position.X.Scale, TopMenu.Position.X.Offset, -0.15, TopMenu.Position.Y.Offset)
212 Time.TextTransparency = 1
213 TimeLabel.TextTransparency = 1
214 TUI.Darkener.BackgroundTransparency = 1
215
216 for i,v in pairs(Library._UI:GetChildren()) do
217 if v.ClassName ~= "Folder" and v.Name ~= "Darkener" and v.Name ~= "MusicPlayer" then
218 v.Visible = true
219 end
220 end
221
222 for i,v in pairs(Library._UI.Widgets:GetChildren()) do
223 v.Visible = true
224 end
225
226 game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
227
228 --// Animate
229 Tween(TUI.Darkener, {BackgroundTransparency = Transparency_Back}, 0.5, true)
230 TandemTween(WidgetPos, Widgets, 0.5)
231 Tween(BottomMenu, {Position = BMPos}, 0.25)
232 Tween(Tabs, {Position = TabsPos}, 0.25)
233 Tween(TopMenu, {Position = TPos}, 0.25, true)
234 end,
235
236 Update = function()
237 if Library.Debounce then return end
238
239 if Library.State == true then
240 Library.Debounce = true
241 Tween(Blur, {Size = 24}, 0.5)
242 Library._UI.Enabled = true
243 Library.Startup()
244 Library.Debounce = false
245 else
246 Library.Debounce = true
247 Library._UI.Enabled = false
248 Tween(Blur, {Size = 0}, 0.5, true)
249 Library.Debounce = false
250 game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
251 end
252 end
253 }
254 Library._UI.Parent = game.CoreGui
255 Library._UI.Enabled = false
256 Library._UI:FindFirstChild("Name").Text = Library.Name
257 Library._UI.IgnoreGuiInset = true
258
259 Library._UI.Lib.Exit.MouseButton1Down:Connect(function()
260 Tween(Library._UI.Lib, {Position = u2(1, 0, Library._UI.Lib.Position.Y.Scale, 0)}, 0.5)
261 end)
262
263 --// Top Menu
264 local TopMenu = Library._UI.Top
265
266 local ELib_Data
267 local _Data = pcall(function()
268 ELib_Data = game:GetService("HttpService"):JSONDecode(readfile("cf.elib"))
269 end)
270
271 function SaveData()
272 writefile(ELib_Data.Config_Name, game:GetService("HttpService"):JSONEncode(ELib_Data))
273 end
274
275 if not _Data then
276 ELib_Data = {
277 Last_Visit = os.date("%x", os.time()),
278 Config_Name = "cf_l.elib",
279 }
280
281 SaveData()
282 end
283
284 TopMenu.last.Text = "last visit: "..ELib_Data.Last_Visit
285 TopMenu.cf.Text = "cf name: "..ELib_Data.Config_Name
286 TopMenu.holder.TextLabel.Text = "welcome, "..game.Players.LocalPlayer.Name
287
288 ELib_Data.Last_Visit = os.date("%x", os.time())
289 SaveData()
290
291 --// Music System
292 local Widgets = Library._UI.Widgets
293 local MusicWidget = Widgets.Music
294
295 local Spotify
296 Spotify = MusicWidget.Spotify.MouseButton1Click:Connect(function()
297 Spotify:Disconnect()
298 task.wait(0.5)
299
300 Tween(MusicWidget.Spotify, {ImageTransparency = 1}, 0.3)
301 Tween(MusicWidget.Soundcloud, {ImageTransparency = 1}, 0.3)
302 task.wait(0.5)
303
304 local String = MusicWidget.Under.Text
305 for i = #MusicWidget.Under.Text, 0, -1 do
306 MusicWidget.Under.Text = string.sub(String, 0, i)
307 task.wait(0.1)
308 end
309
310 local TokenData
311 local Data = pcall(function()
312 TokenData = readfile("spotify.elib")
313 end)
314
315 if not Data then
316 local Typestring = "enter your spotify token"
317 for i = 0, #Typestring, 1 do
318 MusicWidget.Under.Text = string.sub(Typestring, 0, i)
319 task.wait(0.1)
320 end
321 Tween(MusicWidget.TokenBox, {Position = u2(0.5, 0, 0.775, 0)}, 0.5)
322 task.wait(0.5)
323
324 local Focus
325 Focus = MusicWidget.TokenBox.FocusLost:Connect(function()
326 if MusicWidget.TokenBox.Text ~= "" then
327 Focus:Disconnect()
328 writefile("spotify.elib", MusicWidget.TokenBox.Text)
329 TokenData = MusicWidget.TokenBox.Text
330 Tween(MusicWidget.TokenBox, {Position = u2(0.5, 0, 1, 0)}, 0.5)
331 end
332 end)
333 end
334 repeat wait() until TokenData ~= nil
335 local String = MusicWidget.Under.Text
336 for i = #MusicWidget.Under.Text, 0, -1 do
337 MusicWidget.Under.Text = string.sub(String, 0, i)
338 task.wait(0.1)
339 end
340
341 local Typestring = "enjoy"
342 for i = 0, #Typestring, 1 do
343 MusicWidget.Under.Text = string.sub(Typestring, 0, i)
344 task.wait(0.1)
345 end
346
347 --// API stuff
348
349 function ConvertTime(Seconds)
350 local Minutes = (Seconds - Seconds%60)/60
351 Seconds = Seconds - Minutes*60
352
353 local Hours = (Minutes - Minutes%60)/60
354 Minutes = Minutes - Hours*60
355
356 return Format(Minutes)..":"..Format(Seconds)
357 end
358
359 local Spotify = function(url,method,token)
360 local success, res = pcall(syn.request, {
361 Url = url,
362 Method = method,
363 Headers = {
364 ["Accept"] = "application/json",
365 ["Authorization"] = 'Bearer ' .. token,
366 ["Content-Type"] = "application/json"
367 }
368 })
369 if success == true and type(res) == "table" and #res.Body > 0 then
370 local parsed = game.HttpService:JSONDecode(res.Body)
371 return {
372 Artist = parsed['item']['artists'][1]['name'],
373 Title = parsed['item']['name'],
374 Current = parsed['progress_ms'],
375 Maximum = parsed['item']['duration_ms'],
376 Playing = parsed['is_playing'],
377 }
378 else
379 return {
380 Artist = 'Failed to get artist',
381 Title = 'Failed to get song name',
382 Current = 'nil',
383 Maximum = 'nil'
384 }
385 end
386 end
387
388 Tween(MusicWidget.Previous, {ImageTransparency = 0}, 0.3)
389 Tween(MusicWidget.Skip, {ImageTransparency = 0}, 0.3)
390 Tween(MusicWidget.Pause, {ImageTransparency = 0}, 0.3)
391 Library._UI.MusicPlayer.Visible = true
392
393 local MusicPlayer = Library._UI.MusicPlayer
394
395 MusicWidget.Previous.MouseButton1Click:Connect(function()
396 pcall(Spotify, 'https://api.spotify.com/v1/me/player/previous', 'POST', TokenData)
397 end)
398
399 MusicWidget.Skip.MouseButton1Click:Connect(function()
400 pcall(Spotify, 'https://api.spotify.com/v1/me/player/next', 'POST', TokenData)
401 end)
402
403 MusicWidget.Pause.MouseButton1Click:Connect(function()
404 if MusicWidget.Pause.Image == "rbxassetid://6026663719" then
405 pcall(Spotify, 'https://api.spotify.com/v1/me/player/pause', 'PUT', TokenData)
406 else
407 pcall(Spotify, 'https://api.spotify.com/v1/me/player/play', 'PUT', TokenData)
408 end
409 end)
410
411 while wait(0.25) do
412 local Data_, Returned = pcall(Spotify, 'https://api.spotify.com/v1/me/player/currently-playing', 'GET', TokenData)
413 if Data_ then
414 local Current = math.floor(Returned.Current/1000)
415 local Max = math.floor(Returned.Maximum/1000)
416
417 MusicPlayer.Song.Text = Returned.Title
418 MusicPlayer.Author.Text = Returned.Artist
419 MusicPlayer.Time.Text = ConvertTime(Current)
420 MusicPlayer.End.Text = ConvertTime(Max)
421 MusicPlayer.Timeline:TweenSize(u2(Current/Max, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, .25)
422
423 if Returned.Playing then
424 MusicWidget.Pause.Image = "rbxassetid://6026663719"
425 else
426 MusicWidget.Pause.Image = "rbxassetid://6026663699"
427 end
428 if Returned.Artist == "" then
429 MusicPlayer.Author.Text = "No artist found"
430 end
431 end
432 end
433
434
435 end)
436
437 Widgets.Discord.TextButton.MouseButton1Click:Connect(function()
438 setclipboard("This is for aesthetic though i may update it so you can plug your discord here.")
439 end)
440
441 game:GetService("UserInputService").InputBegan:Connect(function(Key, IsTyping)
442 if IsTyping then
443 return
444 end
445
446 if Key.KeyCode == Library.ToggleKey then
447 Library.State = not Library.State
448 Library.Update()
449 end
450 end)
451
452 return setmetatable(Library, LibraryV2)
453end
454
455function LibraryV2:Tab(Name, Icon)
456 local Tab
457 Tab = {
458 Name = Name,
459 Icon = "rbxassetid://"..Icon,
460 Containers = {},
461 Tweens = {},
462
463 Tab = GetAsset("TabTemplate"):Clone(),
464
465 CancelTweens = function()
466 for i, tween in pairs(Tab.Tweens) do
467 tween:Cancel()
468 table.remove(Tab.Tweens, i)
469 end
470 end,
471
472 Update = function(...)
473 Tab.Tab.Icon.Image = Tab.Icon
474 Tab.Tab.Effect.TL.Label.Text = Tab.Name
475
476 local _m = #self.Tabs-1
477 self._UI.TabContainer.Size = u2(0, 71, 0, (80)+(55*_m + (5*(_m+1))))
478 end,
479
480 _UI = self._UI
481 }
482 table.insert(self.Tabs, Tab)
483
484 Tab.Tab.Parent = self._UI.TabContainer.Holder
485 Tab.Update()
486
487 Tab.Tab.MouseEnter:Connect(function()
488 Tab.CancelTweens() --To prevent bugging out
489
490 local TextTween = Tab.Tab.Effect.TL
491 local Tween = game:GetService("TweenService"):Create(TextTween, TweenInfo.new(0.2), {Position = u2(0.5, 0, 0.5, 0)})
492 Tween:Play()
493
494 table.insert(Tab.Tweens, Tween)
495 end)
496
497 Tab.Tab.MouseLeave:Connect(function()
498 Tab.CancelTweens() --To prevent bugging out
499
500 local TextTween = Tab.Tab.Effect.TL
501 local Tween = game:GetService("TweenService"):Create(TextTween, TweenInfo.new(0.2), {Position = u2(1.5, 0, 0.5, 0)})
502 Tween:Play()
503
504 table.insert(Tab.Tweens, Tween)
505 end)
506
507 Tab.Tab.MouseButton1Down:Connect(function()
508 Tween(self._UI.Lib, {Position = u2(0.75, 0, self._UI.Lib.Position.Y.Scale, 0)}, 0.5)
509 self.Hide_All()
510 self.Show(Tab.Containers)
511 end)
512
513 self._UI.Lib.Holder.UIListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
514 self._UI.Lib.Holder.CanvasSize = UDim2.new(0,0,0,self._UI.Lib.Holder.UIListLayout.AbsoluteContentSize.Y)
515 end)
516
517 return setmetatable(Tab, LibraryV2)
518end
519
520function LibraryV2:Container(Name)
521 local Container
522 Container = {
523 Name = Name,
524 Assets = {},
525 Drops = {},
526 Tweens = {},
527 State = false,
528
529 Container = GetAsset("Container"):Clone(),
530
531 CancelTweens = function()
532 for i, tween in pairs(Container.Tweens) do
533 tween:Cancel()
534 table.remove(Container.Tweens, i)
535 end
536 end,
537
538 Update = function(...)
539 Container.Container.TextLabel.Text = Container.Name
540 end,
541
542 In = function()
543 --// Tween the container in
544 Container.CancelTweens()
545 Tween(Container.Container.ImageLabel, {Rotation = 0}, 0.3)
546 local Tween = game:GetService("TweenService"):Create(Container.Container, TweenInfo.new(0.3), {Size = u2(0, 422, 0, 50)})
547 Tween:Play()
548
549 Tween.Completed:Wait()
550 table.insert(Container.Tweens, Tween)
551 end,
552
553 Out = function()
554 --// Tween the container out
555 Container.CancelTweens()
556 Tween(Container.Container.ImageLabel, {Rotation = 180}, 0.3)
557 local Tween = game:GetService("TweenService"):Create(Container.Container, TweenInfo.new(0.3), {Size = u2(0, 422, 0, ((65)+55*#Container.Assets))})
558 Tween:Play()
559
560 table.insert(Container.Tweens, Tween)
561 end
562 }
563 table.insert(self.Containers, Container.Container)
564
565 Container.Container.Parent = self._UI.Lib.Holder
566 Container.Update()
567
568 Container.Container.ImageLabel.MouseButton1Down:Connect(function()
569 if Container.State then
570 Container.In()
571
572 for i,v in pairs(Container.Drops) do
573 if v.State == false then
574 Tween(v.Asset, {Size = u2(0, 407 , 0, 50)}, 0.01)
575 Tween(v.Asset.Image, {Rotation = 0}, 0.01)
576 end
577 end
578 else
579 Container.Out()
580 end
581
582 Container.State = not Container.State
583 end)
584
585 return setmetatable(Container, LibraryV2)
586end
587
588function LibraryV2:Button(Name, Callback)
589 local Button
590 Button = {
591 Name = Name,
592 Callback = Callback or function() end,
593 Class = "Button",
594
595 Asset = GetAsset("Button"):Clone(),
596
597 Update = function(...)
598 Button.Asset.Text = " "..Button.Name
599 end
600 }
601 table.insert(self.Assets, Button.Asset)
602
603 Button.Asset.Visible = true
604 Button.Asset.Parent = self.Container.ScrollingFrame
605 Button.Update()
606
607 Button.Asset.MouseButton1Down:Connect(function(X, Y)
608 pcall(Button.Callback)
609 Ripple(Button.Asset, X, Y)
610 end)
611
612 return setmetatable(Button, LibraryV2)
613end
614
615function LibraryV2:Toggle(Name, StartingState, Callback)
616 local Toggle
617 Toggle = {
618
619 Name = Name,
620 State = StartingState,
621 Callback = Callback or function() end,
622 Class = "Toggle",
623
624 Asset = GetAsset("Toggle"):Clone(),
625
626 Update = function(...)
627 Toggle.Asset.Text = " "..Toggle.Name
628 Toggle.Asset.ImageLabel.Image = (Toggle.State and "rbxassetid://6031068426" or "rbxassetid://6031068433")
629 end
630 }
631 table.insert(self.Assets, Toggle.Asset)
632
633 Toggle.Asset.Visible = true
634 Toggle.Asset.Parent = self.Container.ScrollingFrame
635 Toggle.Update()
636
637 Toggle.Asset.MouseButton1Down:Connect(function(X, Y)
638 Toggle.State = not Toggle.State
639 Toggle.Update()
640
641 pcall(Toggle.Callback, Toggle.State)
642 Ripple(Toggle.Asset, X, Y)
643 end)
644
645 return setmetatable(Toggle, LibraryV2)
646end
647
648function LibraryV2:Dropdown(Name, List, Callback)
649 local Dropdown
650 Dropdown = {
651
652 Name = Name,
653 List = List,
654 Callback = Callback or function() end,
655 State = false,
656 Debounce = false,
657 Class = "Dropdown",
658
659 Asset = GetAsset("Dropdown"):Clone(),
660
661 Other = {
662 ExtensionSize = nil
663 },
664
665 Update = function(...)
666 Dropdown.Asset.NameLabel.Text = " "..Dropdown.Name
667 Dropdown.Other.ExtensionSize = ((70) + (45*#Dropdown.List) + (5*#Dropdown.List))
668
669 if #Dropdown.List > 6 then
670 Dropdown.Other.ExtensionSize = 375;
671 end
672
673 for _, v in pairs(Dropdown.Asset.DropContainer:GetChildren()) do
674 if v:IsA("TextButton") then
675 v:Destroy()
676 end
677 end --// Clear the dropdown
678
679 --// Refresh with New ones
680 local Template = GetAsset("DropdownTemplate")
681 for i,v in pairs(Dropdown.List) do
682 local New_Template = Template:Clone()
683 New_Template.Parent = Dropdown.Asset.DropContainer
684 New_Template.Visible = true
685 New_Template.Text = " " .. v
686 New_Template.Name = v
687
688 New_Template.MouseButton1Down:Connect(function()
689 if Dropdown.State == false then
690 pcall(Dropdown.Callback, v)
691 Dropdown.Debounce = true
692 State = not State
693 Tween(Dropdown.Asset, {Size = u2(0, 407 , 0, 50)}, 0.35)
694 Tween(Dropdown.Asset.Image, {Rotation = 0}, 0.35)
695 Tween(self.Container, {Size = u2(self.Container.Size.X.Scale, self.Container.Size.X.Offset, self.Container.Size.Y.Scale, (self.Container.Size.Y.Offset - (Dropdown.Other.ExtensionSize-50)))}, 0.35)
696
697 task.wait(0.5)
698 Dropdown.Debounce = false
699 end
700 end)
701
702 end
703
704 if #Dropdown.List > 6 then
705 local Content = Dropdown.Asset.DropContainer.UIListLayout.AbsoluteContentSize
706 Dropdown.Asset.DropContainer.CanvasSize = UDim2.new(0, 0, 0, Content.Y + 69);
707 else
708 Dropdown.Asset.DropContainer.CanvasSize = UDim2.new(0, 0, 0, 0);
709 end
710
711 end
712 }
713 table.insert(self.Assets, Dropdown.Asset)
714 table.insert(self.Drops, Dropdown)
715
716 Dropdown.Asset.Visible = true
717 Dropdown.Asset.Parent = self.Container.ScrollingFrame
718 Dropdown.Update()
719
720 Dropdown.Asset.MouseButton1Down:Connect(function(X, Y)
721 if Dropdown.Debounce then return end
722 Ripple(Dropdown.Asset, X, Y)
723
724 if State and Dropdown.Asset.Size.Y.Offset == 50 then
725 State = not State
726 end
727
728 if State then
729 Dropdown.Debounce = true
730 State = not State
731 Tween(Dropdown.Asset, {Size = u2(0, 407, 0, 50)}, 0.35)
732 Tween(Dropdown.Asset.Image, {Rotation = 0}, 0.35)
733 Tween(self.Container, {Size = u2(self.Container.Size.X.Scale, self.Container.Size.X.Offset, self.Container.Size.Y.Scale, (self.Container.Size.Y.Offset - (Dropdown.Other.ExtensionSize-50)))}, 0.35)
734 task.wait(0.5)
735 Dropdown.Debounce = false
736 else
737 Dropdown.Debounce = true
738 State = not State
739 Tween(Dropdown.Asset, {Size = u2(0, 407 , 0, Dropdown.Other.ExtensionSize)}, 0.35)
740 Tween(Dropdown.Asset.Image, {Rotation = 180}, 0.35)
741 Tween(self.Container, {Size = u2(self.Container.Size.X.Scale, self.Container.Size.X.Offset, self.Container.Size.Y.Scale, (self.Container.Size.Y.Offset + (Dropdown.Other.ExtensionSize-50)))}, 0.35)
742
743 task.wait(0.5)
744 Dropdown.Debounce = false
745 end
746 end)
747
748
749 return setmetatable(Dropdown, LibraryV2)
750end
751
752function LibraryV2:Label(Text)
753 local Label
754 Label = {
755 Text = Text,
756 Class = "Label",
757
758 Asset = GetAsset("LabelTemplate"):Clone(),
759
760 Update = function(...)
761 Label.Asset.Text = " "..Label.Text
762 end
763 }
764 table.insert(self.Assets, Label)
765
766 Label.Asset.Visible = true
767 Label.Asset.Parent = self.Container.ScrollingFrame
768 Label.Update()
769
770 return setmetatable(Label, LibraryV2)
771end
772
773function LibraryV2:Keybind(Name, Starting_Key, Blacklisted_Keys, Callback)
774 local Keybind
775 Keybind = {
776
777 Name = Name,
778 Key = Starting_Key or Enum.KeyCode.E,
779 Blacklist = Blacklisted_Keys or {"W", "A", "S", "D"},
780 Callback = Callback or function() end,
781 Debounce = false,
782 Class = "Keybind",
783
784 Asset = GetAsset("Key"):Clone(),
785
786 Connections = {In_Change = false},
787
788 ValidKey = function(Key)
789 return (typeof(Key) == "EnumItem")
790 end,
791
792 GetKeystringFromEnum = function(Key)
793 Key = tostring(Key)
794
795 if Key == "..." then
796 return "..."
797 end
798
799 return ( string.sub( Key, 14, #Key ) )
800 end,
801
802 IsNotMouse = function(Key)
803 return (Key.UserInputType == Enum.UserInputType.MouseButton1 or Key.UserInputType == Enum.UserInputType.MouseButton2)
804 end,
805
806 Update = function(...)
807 Keybind.Asset.Text = " "..Keybind.Name
808 Keybind.Asset.Key_Back.Key_Label.Text = Keybind.GetKeystringFromEnum(Keybind.Key)
809 end
810 }
811 table.insert(self.Assets, Keybind.Asset)
812
813 Keybind.Asset.Visible = true
814 Keybind.Asset.Parent = self.Container.ScrollingFrame
815 Keybind.Update()
816
817 Keybind.Connections.KeyPress = game:GetService("UserInputService").InputBegan:Connect(function(Input, GameProcessedEvent)
818 if GameProcessedEvent then return end
819
820 if Input.KeyCode == Keybind.Key and not Keybind.Connections.In_Change == true then
821 pcall(Keybind.Callback)
822 end
823 end)
824
825 Keybind.Asset.MouseButton1Down:Connect(function(X, Y)
826 if not Keybind.Debounce then
827 Keybind.Debounce = true
828 Keybind.Connections.In_Change = true
829 Ripple(Keybind.Asset, X, Y)
830
831 local Continue = false
832 local Cache = {}
833 Cache.OldText = Keybind.Name
834 Cache.OldKey = Keybind.Key
835
836 Keybind.Name = Keybind.Name .. " [press enter to cancel]"
837 Keybind.Key = "..."
838 Keybind.Update()
839
840 Keybind.Connections.Change_Connection = game:GetService("UserInputService").InputBegan:Connect(function(Input, GameProcessedEvent)
841 if GameProcessedEvent then return end
842 if Keybind.IsNotMouse(Input) then return end
843
844 if Input.KeyCode == Enum.KeyCode.Return then
845 Continue = true
846 Keybind.Key = Cache.OldKey
847 Keybind.Connections.Change_Connection:Disconnect()
848
849 Keybind.Update()
850 end
851
852 if not Continue and not table.find(Keybind.Blacklist, Keybind.GetKeystringFromEnum(Input.KeyCode)) then
853 Keybind.Key = Input.KeyCode
854 Keybind.Update()
855 Continue = true
856
857 pcall(Keybind.Callback, Keybind.GetKeystringFromEnum(Keybind.Key))
858 Keybind.Connections.Change_Connection:Disconnect()
859 end
860 end)
861 repeat wait() until Continue
862 Keybind.Name = Cache.OldText
863 Keybind.Connections.In_Change = false
864 Cache = nil
865
866 Keybind.Update()
867 wait(0.5)
868 Keybind.Debounce = false
869 end
870 end)
871
872end
873
874function LibraryV2:TextBox(Name, Callback)
875 local TextBox
876 TextBox = {
877
878 Name = Name,
879 Callback = Callback or function() end,
880 CanCall = true,
881 Class = "TextBox",
882
883 Asset = GetAsset("Textbox"):Clone(),
884
885 Update = function(...)
886 TextBox.Asset.Text = " "..TextBox.Name
887
888 local Args = {...}
889 if Args[1] then
890 TextBox.Asset.Cover.BoxText.Text = Args[1]
891 pcall(TextBox.Callback, Args[1])
892 end
893 end
894 }
895 table.insert(self.Assets, TextBox.Asset)
896
897 TextBox.Asset.Visible = true
898 TextBox.Asset.Parent = self.Container.ScrollingFrame
899 TextBox.Update()
900
901 TextBox.Asset.Cover.BoxText.Focused:Connect(function()
902 if TextBox.CanCall then
903 TextBox.Asset.Cover.BoxText:ReleaseFocus()
904 end
905 end)
906
907 TextBox.Asset.MouseButton1Down:Connect(function(X, Y)
908 if TextBox.CanCall then
909 TextBox.CanCall = false
910 Ripple(TextBox.Asset, X, Y)
911
912 TextBox.Asset.Cover.BoxText:CaptureFocus()
913 TextBox.Asset.Cover.BoxText.FocusLost:Wait()
914 pcall(TextBox.Callback, TextBox.Asset.Cover.BoxText.Text)
915
916 task.wait(0.2)
917 TextBox.CanCall = true
918 end
919 end)
920end
921
922function LibraryV2:Slider(Name, Min, Max, Start, Callback, Use_Decimals)
923 local Slider
924 Slider = {
925
926 Name = Name,
927 Min = Min or 0,
928 Max = Max or 100,
929 Value = Start or math.floor((Max/2)+0.5),
930 Callback = Callback or function() end,
931 Class = "Slider",
932
933 Values = {
934 Dragging = false,
935
936 },
937
938 Asset = GetAsset("Slider"):Clone(),
939
940 Update = function(...)
941 Slider.Asset:FindFirstChild("Name").Text = Slider.Name
942
943 local New = Slider.Value
944 Slider.Asset.Slider_Whole.Slider:TweenSize(UDim2.new((New or 0) / Slider.Max, 0, 1, 0), "Out", "Sine", 0.1, true)
945 Slider.Asset.Percentage.Text = tostring(New)
946
947 --[[
948 if bool then
949 pcall(Slider.Callback, New)
950 end--]]
951 end
952 }
953 table.insert(self.Assets, Slider.Asset)
954
955 Slider.Asset.Name = Slider.Name
956 Slider.Asset.Visible = true
957 Slider.Asset.Parent = self.Container.ScrollingFrame
958 Slider.Update()
959
960 Slider.Asset.Slider_Whole.Slider.Circle.InputBegan:Connect(
961 function(Input)
962 if Input.UserInputType == Enum.UserInputType.MouseButton1 then
963 Slider.Dragging = true
964 end
965 end
966 )
967 Slider.Asset.Slider_Whole.Slider.Circle.InputEnded:Connect(
968 function(Input)
969 if Input.UserInputType == Enum.UserInputType.MouseButton1 then
970 Slider.Dragging = false
971 end
972 end
973 )
974
975 game:GetService("UserInputService").InputChanged:Connect(
976 function(Input)
977 if Slider.Dragging and Input.UserInputType == Enum.UserInputType.MouseMovement then
978 local Bound = Slider.Asset.Slider_Whole.AbsoluteSize.X
979 local Pos1 =
980 UDim2.new(
981 math.clamp((Input.Position.X - Slider.Asset.Slider_Whole.Slider.AbsolutePosition.X) / Bound, 0, 1),
982 0,
983 1,
984 0
985 )
986 Slider.Asset.Slider_Whole.Slider:TweenSize(Pos1, "Out", "Sine", 0.1, true)
987 Slider.Value = (Use_Decimals and RoundNumber((((Pos1.X.Scale * Slider.Max) / Slider.Max) * (Slider.Max - Slider.Min) + Slider.Min), 1) or math.floor((((Pos1.X.Scale * Slider.Max) / Slider.Max) * (Slider.Max - Slider.Min) + Slider.Min)))
988 Slider.Asset.Percentage.Text = tostring(Slider.Value)
989 pcall(Slider.Callback, Slider.Value)
990 end
991 end
992 )
993
994end
995
996function LibraryV2:Update(a_1, ...)
997 local Class = self.Class;
998
999 if (...) then
1000 for i,v in pairs({...}) do
1001 self[i] = v
1002 end
1003 end;
1004
1005 if not a_1 then return end;
1006 if Class == "Button" then
1007 self.Callback = a_1;
1008 elseif Class == "Toggle" then
1009 self.State = a_1;
1010 self.Update();
1011 pcall(self.Callback, self.State)
1012 elseif Class == "Label" then
1013 self.Text = a_1;
1014 elseif Class == "Slider" then
1015 self.Value = a_1;
1016 elseif Class == "Dropdown" then
1017 self.List = a_1;
1018 end
1019
1020 self.Update();
1021end
1022
1023function LibraryV2:UpdateNotifications()
1024
1025 --// GET RID OF THE LOSER NOTIFICATIONS LOL
1026 for i,v in pairs(LibraryV2.Notifications) do
1027 if (tick()-v.Data.TOC) >= v.Data.Last then
1028 --// Remove
1029 --inst, tType, t, yield, pref
1030 local Notif = v.Data.Notification
1031 Tween(Notif, {Position = u2(1, Notif.Position.X.Offset, Notif.Position.Y.Scale, Notif.Position.Y.Offset)}, 0.55)
1032
1033 delay(0.55, function()
1034 Notif:Destroy()
1035 end)
1036 table.remove(LibraryV2.Notifications, i)
1037 end
1038 end
1039
1040 if #LibraryV2.Notifications > 1 then
1041 table.sort(LibraryV2.Notifications, function(a, b)
1042 return a.Data.Queue < b.Data.Queue
1043 end)
1044 end
1045
1046 for i,v in ipairs(LibraryV2.Notifications) do
1047 --Let's determine if its a new notification or already tweened
1048 local Move_Axis = (0.902 - (0.1 * (i-1)))
1049 if v.Data.Notification.Position.X.Scale == 1 then
1050 -- New
1051 v.Data.Notification.Position = u2(1, v.Data.Notification.Position.X.Offset, Move_Axis, v.Data.Notification.Position.Y.Offset)
1052 Tween(v.Data.Notification, {Position = u2(0.825, v.Data.Notification.Position.X.Offset, Move_Axis, v.Data.Notification.Position.Y.Offset)}, 0.5)
1053 else
1054 -- Old
1055 Tween(v.Data.Notification, {Position = u2(0.825, v.Data.Notification.Position.X.Offset, Move_Axis, v.Data.Notification.Position.Y.Offset)}, 0.5)
1056 end
1057 end
1058end
1059
1060function LibraryV2:Notification(Title, Info, Icon, Last)
1061 if #LibraryV2.Notifications >= 5 then
1062 print("You have too many notifications ongoing.")
1063 return
1064 end
1065
1066 local Notification
1067 Notification = {
1068
1069 Title = Title or "None",
1070 Info = Info or "No Info",
1071 Icon = Icon and "rbxassetid://" .. Icon or "rbxassetid://6031071053",
1072
1073 Data = {
1074 Queue = #LibraryV2.Notifications+1,
1075 Notification = GetAsset("Notification"):Clone(),
1076 TOC = tick(),
1077 Last = Last or 3
1078 }
1079 }
1080 Notification.Data.Notification.Name = Notification.Data.Queue
1081 Notification.Data.Notification.Bottom.Text = Notification.Info
1082 Notification.Data.Notification.Top.Text = Notification.Title
1083 Notification.Data.Notification.Icon.Image = Notification.Icon
1084 Notification.Data.Notification.Parent = GetAsset("Notifications")
1085 table.insert(LibraryV2.Notifications, Notification)
1086
1087 delay(Last+0.05, function()
1088 LibraryV2:UpdateNotifications()
1089 end)
1090 LibraryV2:UpdateNotifications()
1091end
1092
1093function LibraryV2:SetToggleKey(Key)
1094 delay(0.05, function()
1095 self.ToggleKey = Key
1096 end)
1097end
1098
1099return LibraryV2