-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.lua
More file actions
1792 lines (1495 loc) · 60.8 KB
/
Copy pathlib.lua
File metadata and controls
1792 lines (1495 loc) · 60.8 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[
暗い kurai.
a sleek roblox ui library based around simplicity, modern design, and csgo inspired aesthetics.
created by @focat on discord - dm me before using any code from this commercially
licensed under Creative Commons Zero v.10 Universal (CC0 1.0) Public Domain Dedication
> states that you may share/modify this code as you please, but NOT commercially
> you also must give credit where it is due!
enjoy!
sorry for messy code :(
]]--
local Kurai_Lib = {}
Kurai_Lib.__index = Kurai_Lib
local TweenService = game:GetService("TweenService") -- ts pmo!!!!!!!!!
local UserInputService = game:GetService("UserInputService")
Kurai_Lib.Settings = {
ToggleKey = Enum.KeyCode.RightControl,
TogglingUI = false
}
Kurai_Lib.Flags = {}
Kurai_Lib.Theme = {
Main = Color3.fromRGB(42, 66, 117),
Tab = Color3.fromRGB(10, 13, 66, 1),
TabAccent = Color3.fromRGB(30, 30, 30),
Content = Color3.fromRGB(25, 25, 25),
Accent = Color3.fromRGB(33, 47, 129),
Text = Color3.fromRGB(212, 212, 212),
SubText = Color3.fromRGB(89, 89, 89)
}
function Kurai_Lib.Tween(obj, goal, time, style, direction)
local tween = TweenService:Create(obj, TweenInfo.new(time or 0.5, style or Enum.EasingStyle.Quint, direction or Enum.EasingDirection.Out), goal)
tween:Play()
return tween
end
function Kurai_Lib.RippleEffect(btnInstance, color)
local ripple = Instance.new("Frame")
ripple.Name = "Ripple"
ripple.BackgroundColor3 = color or Kurai_Lib.Theme.Accent
ripple.BackgroundTransparency = 0.8
ripple.Size = UDim2.new(0, 0, 0, 0)
ripple.ZIndex = 10
ripple.Parent = btnInstance
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(1, 0)
corner.Parent = ripple
local mouse = UserInputService:GetMouseLocation()
local buttonPos = btnInstance.AbsolutePosition
local relativeX = mouse.X - buttonPos.X
local relativeY = mouse.Y - buttonPos.Y
ripple.Position = UDim2.new(0, relativeX, 0, relativeY)
ripple.AnchorPoint = Vector2.new(0.5, 0.5)
local targetSize = math.max(btnInstance.AbsoluteSize.X, btnInstance.AbsoluteSize.Y) * 2.5
Kurai_Lib.Tween(ripple, {
Size = UDim2.new(0, targetSize, 0, targetSize),
Position = UDim2.new(0, relativeX, 0, relativeY),
BackgroundTransparency = 1
}, 0.5)
game:GetService("Debris"):AddItem(ripple, 0.6)
end
function Kurai_Lib.new(options)
options = options or {}
local self = setmetatable({}, Kurai_Lib)
self.ScreenGui = Instance.new("ScreenGui")
self.ScreenGui.Name = options.Name or "Kurai_Lib"
self.ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Global
self.ScreenGui.ResetOnSpawn = false
self.ScreenGui.DisplayOrder = 1000
self.ScreenGui.Parent = gethui and gethui() or game:GetService("CoreGui")
self.Notifications = {}
self.Open = true
self:_internal_createloader(options)
return self
end
function Kurai_Lib:ToggleUI()
if Kurai_Lib.Settings.TogglingUI then
return
end
Kurai_Lib.Settings.TogglingUI = true
self.Open = not self.Open
if self.Open then
self.MainWindow.Visible = true
self.MainWindow.BackgroundTransparency = 1
local startPos = UDim2.new(
self.MainWindow.Position.X.Scale,
self.MainWindow.Position.X.Offset,
1, 500
)
local targetPos = UDim2.new(
0.5, -self.MainWindow.AbsoluteSize.X/2,
0.5, -self.MainWindow.AbsoluteSize.Y/2
)
self.MainWindow.Position = startPos
Kurai_Lib.Tween(self.MainWindow, {
Position = targetPos,
BackgroundTransparency = 0
})
Kurai_Lib.Settings.TogglingUI = false
else
local currentPos = self.MainWindow.Position
local targetPos = UDim2.new(
currentPos.X.Scale,
currentPos.X.Offset,
1, 500
)
Kurai_Lib.Tween(self.MainWindow, {
Position = targetPos,
BackgroundTransparency = 1
})
task.wait(0.5) -- default tween time in .Tween lol
Kurai_Lib.Settings.TogglingUI = false
self.MainWindow.Visible = false
end
end
function Kurai_Lib:Notify(props)
props = props or {}
local title = props.Title or "Notification"
local message = props.Message or ""
local duration = props.Duration or 5
local notificationType = props.Type or "info"
local notification = Instance.new("Frame")
notification.Name = "Notification"
notification.Size = UDim2.new(0, 300, 0, 0)
notification.Position = UDim2.new(1, -10, 1, 10) -- start below screen
notification.AnchorPoint = Vector2.new(1, 1)
notification.BackgroundColor3 = Kurai_Lib.Theme.Content
notification.BorderSizePixel = 0
notification.ClipsDescendants = true
notification.ZIndex = self.ScreenGui.DisplayOrder + 1
notification.Parent = self.ScreenGui
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 4)
corner.Parent = notification
local accentColor = Kurai_Lib.Theme.Accent
if notificationType == "success" then
accentColor = Color3.fromRGB(76, 175, 80)
elseif notificationType == "warn" then
accentColor = Color3.fromRGB(255, 193, 7)
elseif notificationType == "err" then
accentColor = Color3.fromRGB(244, 67, 54)
end
local accentBar = Instance.new("Frame")
accentBar.Name = "AccentBar"
accentBar.Size = UDim2.new(0, 3, 1, 0)
accentBar.BackgroundColor3 = accentColor
accentBar.BorderSizePixel = 0
accentBar.ZIndex = notification.ZIndex + 1
accentBar.Parent = notification
local accentBarCorner = Instance.new("UICorner")
accentBarCorner.CornerRadius = UDim.new(0, 4)
accentBarCorner.Parent = accentBar
local padding = Instance.new("UIPadding")
padding.PaddingLeft = UDim.new(0, 0) -- 0 for accent bar
padding.PaddingRight = UDim.new(0, 10)
padding.PaddingTop = UDim.new(0, 10)
padding.PaddingBottom = UDim.new(0, 10)
padding.Parent = notification
local titleLabel = Instance.new("TextLabel")
titleLabel.Name = "Title"
titleLabel.Size = UDim2.new(1, -25, 0, 20)
titleLabel.Position = UDim2.new(0, 15, 0, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = title
titleLabel.TextColor3 = Kurai_Lib.Theme.Text
titleLabel.TextSize = 16
titleLabel.Font = Enum.Font.RobotoMono
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.ZIndex = accentBar.ZIndex
titleLabel.Parent = notification
local messageLabel = Instance.new("TextLabel")
messageLabel.Name = "Message"
messageLabel.Size = UDim2.new(1, -25, 0, 0)
messageLabel.Position = UDim2.new(0, 15, 0, 25)
messageLabel.BackgroundTransparency = 1
messageLabel.Text = message
messageLabel.TextColor3 = Kurai_Lib.Theme.SubText
messageLabel.TextSize = 14
messageLabel.Font = Enum.Font.RobotoMono
messageLabel.TextXAlignment = Enum.TextXAlignment.Left
messageLabel.TextYAlignment = Enum.TextYAlignment.Top
messageLabel.TextWrapped = true
messageLabel.ZIndex = accentBar.ZIndex
messageLabel.Parent = notification
local textService = game:GetService("TextService")
local textSize = textService:GetTextSize(
message,
14,
Enum.Font.RobotoMono,
Vector2.new(265, math.huge)
)
messageLabel.Size = UDim2.new(1, -25, 0, textSize.Y)
notification.Size = UDim2.new(0, 300, 0, textSize.Y + 45)
Kurai_Lib.Tween(notification, {
Position = UDim2.new(1, -10, 1, -10)
}, 0.3)
local totalHeight = notification.AbsoluteSize.Y + 10
for _, existingNotif in next, self.Notifications do
if existingNotif and existingNotif.Parent then
local currentPos = existingNotif.Position
Kurai_Lib.Tween(existingNotif, {
Position = UDim2.new(
currentPos.X.Scale, currentPos.X.Offset,
currentPos.Y.Scale, currentPos.Y.Offset - totalHeight
)
}, 0.3)
end
end
table.insert(self.Notifications, notification)
task.spawn(function()
task.wait(duration)
Kurai_Lib.Tween(notification, {
BackgroundTransparency = 1
}, 0.3)
Kurai_Lib.Tween(titleLabel, {
TextTransparency = 1
}, 0.3)
Kurai_Lib.Tween(messageLabel, {
TextTransparency = 1
}, 0.3)
Kurai_Lib.Tween(accentBar, {
BackgroundTransparency = 1
}, 0.3)
task.wait(0.3)
for i, notif in next, self.Notifications do
if notif == notification then
table.remove(self.Notifications, i)
break
end
end
for _, remainingNotif in next, self.Notifications do
if remainingNotif and remainingNotif.Parent then
local currentPos = remainingNotif.Position
Kurai_Lib.Tween(remainingNotif, {
Position = UDim2.new(
currentPos.X.Scale, currentPos.X.Offset,
currentPos.Y.Scale, currentPos.Y.Offset + totalHeight
)
}, 0.3)
end
end
notification:Destroy()
end)
return notification
end
function Kurai_Lib:_internal_createloader(options)
self.Loader = Instance.new("Frame")
self.Loader.Name = "Loader"
self.Loader.BackgroundColor3 = Kurai_Lib.Theme.Main
self.Loader.BorderSizePixel = 0
self.Loader.Position = UDim2.new(0.5, -150, 0.5, -150)
self.Loader.Size = UDim2.new(0, 300, 0, 300)
self.Loader.Visible = false
self.Loader.Parent = self.ScreenGui
-- [ Loader elements (status bar, text, etc) ]
self.LoaderBar = Instance.new("Frame")
self.LoaderBar.Name = "LoaderBar"
self.LoaderBar.BackgroundColor3 = Kurai_Lib.Theme.Accent
self.LoaderBar.BorderSizePixel = 0
self.LoaderBar.Size = UDim2.new(0, 300, 0, 1)
self.LoaderBar.Parent = self.Loader
-- [ gay rainbow ]
Kurai_Lib.Rainbow(self.LoaderBar, 0.5)
self.StatusText = Instance.new("TextLabel")
self.StatusText.Name = "StatusText"
self.StatusText.Font = Enum.Font.RobotoMono
self.StatusText.Text = "initializing..."
self.StatusText.TextColor3 = Kurai_Lib.Theme.SubText
self.StatusText.TextSize = 14
self.StatusText.BackgroundTransparency = 1
self.StatusText.Position = UDim2.new(0.5, -150, 0.1, 0)
self.StatusText.Size = UDim2.new(0, 300, 0, 21)
self.StatusText.Parent = self.Loader
self.LoaderLogo = Instance.new("ImageLabel")
self.LoaderLogo.Image = "rbxassetid://108502703403650"
self.LoaderLogo.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
self.LoaderLogo.BackgroundTransparency = 1
self.LoaderLogo.BorderColor3 = Color3.fromRGB(0, 0, 0)
self.LoaderLogo.BorderSizePixel = 0
self.LoaderLogo.Position = UDim2.new(0.416666657, -100, 0.416666657, -100)
self.LoaderLogo.Size = UDim2.new(0, 250, 0, 250)
self.LoaderLogo.Parent = self.Loader
self.LoaderCredits = Instance.new("TextLabel")
self.LoaderCredits.Font = Enum.Font.RobotoMono
self.LoaderCredits.Text = "B | Scripts"
self.LoaderCredits.TextColor3 = Color3.fromRGB(89.00000229477882, 89.00000229477882, 89.00000229477882)
self.LoaderCredits.TextSize = 12
self.LoaderCredits.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
self.LoaderCredits.BackgroundTransparency = 1
self.LoaderCredits.BorderColor3 = Color3.fromRGB(0, 0, 0)
self.LoaderCredits.BorderSizePixel = 0
self.LoaderCredits.Position = UDim2.new(0.5, -150, 0.906666696, 0)
self.LoaderCredits.Size = UDim2.new(0, 300, 0, 21)
self.LoaderCredits.Name = "credits"
self.LoaderCredits.Parent = self.Loader
self:_internal_initload(options)
end
function Kurai_Lib:_internal_initload(options)
self.Loader.Visible = true
Kurai_Lib.Tween(self.Loader, {BackgroundTransparency = 0})
-- ts pmo (doesnt do anything related to version checking YET...)
self:_internal_setloaderstatus("fetching version...")
task.wait(0.5)
self:_internal_setloaderstatus("comparing local <-> remote...")
task.wait(1)
self:_internal_setloaderstatus("remote == local")
task.wait(1)
self:_internal_setloaderstatus("loading components...")
task.wait(2)
self:_internal_setloaderstatus("initializing UI...")
task.wait(1)
self:_internal_createmainwindow(options)
Kurai_Lib.Tween(self.Loader, {BackgroundTransparency = 1})
-- [ fade out all text, images, frames ]
for _, child in next, self.Loader:GetDescendants() do
if child:IsA("GuiObject") then
Kurai_Lib.Tween(child, {BackgroundTransparency = 1})
if child:IsA("TextLabel") or child:IsA("TextButton") then
Kurai_Lib.Tween(child, {TextTransparency = 1})
end
if child:IsA("ImageLabel") or child:IsA("ImageButton") then
Kurai_Lib.Tween(child, {ImageTransparency = 1})
end
end
end
task.wait(0.5)
self.Loader.Visible = false
end
function Kurai_Lib:_internal_setloaderstatus(text)
self.StatusText.Text = text
end
function Kurai_Lib:_internal_createmainwindow(options)
self.MainWindow = Instance.new("Frame")
self.MainWindow.Name = "MainWindow"
self.MainWindow.Size = UDim2.new(0, 500, 0, 500)
self.MainWindow.Position = UDim2.new(0.5, -250, 0.5, -250)
self.MainWindow.AnchorPoint = Vector2.new(0.5, 0.5)
self.MainWindow.BackgroundColor3 = Kurai_Lib.Theme.Main
self.MainWindow.BorderSizePixel = 0
self.MainWindow.ClipsDescendants = true
self.MainWindow.Parent = self.ScreenGui
self.TitleBar = Instance.new("Frame")
self.TitleBar.Name = "TitleBar"
self.TitleBar.Size = UDim2.new(1, 0, 0, 53)
self.TitleBar.BackgroundTransparency = 1
self.TitleBar.Parent = self.MainWindow
self.TitleAccent = Instance.new("Frame")
self.TitleAccent.Name = "TitleAccent"
self.TitleAccent.BackgroundColor3 = Kurai_Lib.Theme.Accent
self.TitleAccent.BorderSizePixel = 0
self.TitleAccent.Size = UDim2.new(1, 0, 0, 1)
self.TitleAccent.Parent = self.TitleBar
self.GameTitle = Instance.new("TextLabel")
self.GameTitle.Name = "GameTitle"
self.GameTitle.Font = Enum.Font.RobotoMono
self.GameTitle.Text = options.GameName or "[GAME NAME]"
self.GameTitle.TextColor3 = Kurai_Lib.Theme.Text
self.GameTitle.TextSize = 18
self.GameTitle.TextXAlignment = Enum.TextXAlignment.Left
self.GameTitle.BackgroundTransparency = 1
self.GameTitle.Position = UDim2.new(0.43, -150, 0.44, -9)
self.GameTitle.Size = UDim2.new(0, 300, 0, 18)
self.GameTitle.Parent = self.TitleBar
self.LogoIcon = Instance.new("ImageLabel")
self.LogoIcon.Image = "rbxassetid://108502703403650"
self.LogoIcon.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
self.LogoIcon.BackgroundTransparency = 1
self.LogoIcon.BorderColor3 = Color3.fromRGB(0, 0, 0)
self.LogoIcon.BorderSizePixel = 0
self.LogoIcon.Position = UDim2.new(0.0659999996, -25, 0.613207519, -25)
self.LogoIcon.Size = UDim2.new(0, 50, 0, 50)
self.LogoIcon.Name = "icon"
self.LogoIcon.Parent = self.TitleBar
self.ScriptHubName = Instance.new("TextLabel")
self.ScriptHubName.Name = "ScriptHubName"
self.ScriptHubName.Font = Enum.Font.RobotoMono
self.ScriptHubName.Text = options.ScriptHubName or "JEWISH SCRIPT HUB"
self.ScriptHubName.TextColor3 = Kurai_Lib.Theme.SubText
self.ScriptHubName.TextSize = 18
self.ScriptHubName.TextXAlignment = Enum.TextXAlignment.Left
self.ScriptHubName.BackgroundTransparency = 1
self.ScriptHubName.Position = UDim2.new(0.43, -150, 0.78, -9)
self.ScriptHubName.Size = UDim2.new(0, 300, 0, 18)
self.ScriptHubName.Parent = self.TitleBar
self.TabContainer = Instance.new("Frame")
self.TabContainer.Name = "TabContainer"
self.TabContainer.Size = UDim2.new(1, 0, 0, 35)
self.TabContainer.Position = UDim2.new(0, 0, 0.12, 0)
self.TabContainer.BackgroundTransparency = 1
self.TabContainer.BorderSizePixel = 0
self.TabContainer.Parent = self.MainWindow
self.ContentContainer = Instance.new("Frame")
self.ContentContainer.Name = "ContentContainer"
self.ContentContainer.Size = UDim2.new(1, -20, 1, -100)
self.ContentContainer.Position = UDim2.new(0, 10, 0, 95)
self.ContentContainer.BackgroundTransparency = 1
self.ContentContainer.BorderSizePixel = 0
self.ContentContainer.Parent = self.MainWindow
self:InitTabs(options.Tabs or {"Main", "Visuals", "Settings"})
-- [ toggle key ]
UserInputService.InputBegan:Connect(function(input, gpe)
if not gpe and input.KeyCode == Kurai_Lib.Settings.ToggleKey then
self:ToggleUI()
end
end)
-- [ make draggable ]
self:Draggable(self.MainWindow, self.TitleBar)
end
function Kurai_Lib:SetToggleKeybind(keyCode)
if keyCode and table.find(Enum.KeyCode:GetEnumItems(), keyCode) then
Kurai_Lib.Settings.ToggleKey = keyCode
else
warn("[Kurai] Invalid keybind!")
end
end
function Kurai_Lib:Draggable(frame, handle)
local dragStartPos, frameStartPos
handle.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragStartPos = input.Position
frameStartPos = frame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragStartPos = nil
end
end)
end
end)
handle.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement and dragStartPos then
local delta = input.Position - dragStartPos
frame.Position = UDim2.new(
frameStartPos.X.Scale, frameStartPos.X.Offset + delta.X,
frameStartPos.Y.Scale, frameStartPos.Y.Offset + delta.Y
)
end
end)
end
function Kurai_Lib:InitTabs(tabNames)
self.Tabs = {}
self.CurrentTab = nil
local tabButtonsContainer = Instance.new("ScrollingFrame")
tabButtonsContainer.Name = "TabButtons"
tabButtonsContainer.AutomaticCanvasSize = Enum.AutomaticSize.X
tabButtonsContainer.ScrollBarThickness = 0
tabButtonsContainer.ScrollingDirection = Enum.ScrollingDirection.X
tabButtonsContainer.BackgroundTransparency = 1
tabButtonsContainer.BorderSizePixel = 0
tabButtonsContainer.Size = UDim2.new(1, 0, 1, 0)
tabButtonsContainer.Parent = self.TabContainer
local tabListLayout = Instance.new("UIListLayout")
tabListLayout.Padding = UDim.new(0, 5)
tabListLayout.FillDirection = Enum.FillDirection.Horizontal
tabListLayout.SortOrder = Enum.SortOrder.LayoutOrder
tabListLayout.Parent = tabButtonsContainer
local tabPadding = Instance.new("UIPadding")
tabPadding.PaddingLeft = UDim.new(0, 10)
tabPadding.PaddingRight = UDim.new(0, 10)
tabPadding.Parent = tabButtonsContainer
for i, tabName in next, tabNames do
local tabButton = Instance.new("TextButton")
tabButton.Name = tabName
tabButton.Text = tabName
tabButton.Font = Enum.Font.RobotoMono
tabButton.TextColor3 = Kurai_Lib.Theme.Text
tabButton.TextSize = 14
tabButton.BackgroundColor3 = Kurai_Lib.Theme.Tab
tabButton.Size = UDim2.new(0.23, 0, 0, 34)
tabButton.LayoutOrder = i
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 4)
corner.Parent = tabButton
tabButton.Parent = tabButtonsContainer
local tabContent = Instance.new("ScrollingFrame")
tabContent.Name = tabName.."Content"
tabContent.Size = UDim2.new(1, 0, 1, 0)
tabContent.BackgroundTransparency = 1
tabContent.ScrollBarThickness = 4
tabContent.ScrollBarImageColor3 = Kurai_Lib.Theme.Content
tabContent.BorderSizePixel = 0
tabContent.Visible = false
tabContent.Parent = self.ContentContainer
tabContent.AutomaticCanvasSize = Enum.AutomaticSize.Y
tabContent.CanvasSize = UDim2.new(0, 0, 0, 0)
local contentListLayout = Instance.new("UIListLayout")
contentListLayout.Padding = UDim.new(0, 10)
contentListLayout.SortOrder = Enum.SortOrder.LayoutOrder
contentListLayout.Parent = tabContent
local contentPadding = Instance.new("UIPadding")
contentPadding.PaddingTop = UDim.new(0, 10)
contentPadding.PaddingLeft = UDim.new(0, 10)
contentPadding.PaddingRight = UDim.new(0, 10)
contentPadding.PaddingBottom = UDim.new(0, 10)
contentPadding.Parent = tabContent
self.Tabs[tabName] = {
TabButton = tabButton,
Content = tabContent,
Elements = {},
Label = function(tabObj, props)
return self:_createLabel(tabName, props)
end,
Splitter = function(tabObj, props)
return self:_createSplitter(tabName, props)
end,
Button = function(tabObj, props, flag)
return self:_createButton(tabName, props, flag)
end,
Toggle = function(tabObj, props, flag)
return self:_createToggle(tabName, props, flag)
end,
Slider = function(tabObj, props, flag)
return self:_createSlider(tabName, props, flag)
end,
Dropdown = function(tabObj, props, flag)
return self:_createDropdown(tabName, props, flag)
end,
Keybind = function(tabObj, props, flag)
return self:_createKeybind(tabName, props, flag)
end,
TextField = function(tabObj, props, flag)
return self:_createTextField(tabName, props, flag)
end
}
tabButton.MouseButton1Click:Connect(function()
self:SwitchTab(tabName)
end)
end
if #tabNames > 0 then
self:SwitchTab(tabNames[1])
end
end
function Kurai_Lib:SwitchTab(tabName)
if self.CurrentTab then
Kurai_Lib.Tween(self.CurrentTab.TabButton, {BackgroundColor3 = Kurai_Lib.Theme.Tab})
self.CurrentTab.Content.Visible = false
end
self.CurrentTab = self.Tabs[tabName]
Kurai_Lib.Tween(self.CurrentTab.TabButton, {BackgroundColor3 = Kurai_Lib.Theme.TabAccent})
self.CurrentTab.Content.Visible = true
end
function Kurai_Lib:_createButton(tabName, props, flag)
props = props or {}
local tab = self.Tabs[tabName]
if not tab then return nil end
local btnInstance = Instance.new("TextButton")
btnInstance.Name = props.Text or "Button"
btnInstance.Text = props.Text or "Button"
btnInstance.Font = Enum.Font.RobotoMono
btnInstance.TextColor3 = Kurai_Lib.Theme.Text
btnInstance.TextSize = 16
btnInstance.BackgroundColor3 = Kurai_Lib.Theme.Tab
btnInstance.Size = UDim2.new(1, 0, 0, 35)
btnInstance.LayoutOrder = #tab.Elements + 1
btnInstance.Parent = tab.Content
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 3)
corner.Parent = btnInstance
btnInstance.MouseEnter:Connect(function()
Kurai_Lib.Tween(btnInstance, {BackgroundColor3 = Kurai_Lib.Theme.Accent})
end)
btnInstance.MouseLeave:Connect(function()
Kurai_Lib.Tween(btnInstance, {BackgroundColor3 = Kurai_Lib.Theme.Tab})
end)
btnInstance.MouseButton1Click:Connect(function()
Kurai_Lib.RippleEffect(btnInstance)
if props.Callback then
props.Callback(btnInstance)
end
end)
if flag then
self.Flags = self.Flags or {}
self.Flags[flag] = btnInstance
end
table.insert(tab.Elements, btnInstance)
local control = {
Instance = btnInstance,
Click = function()
if props.Callback then
props.Callback(btnInstance)
end
return control
end
}
return control
end
function Kurai_Lib:_createLabel(tabName, props)
props = props or {}
local tab = self.Tabs[tabName]
if not tab then return nil end
local label = Instance.new("TextLabel")
label.Name = props.Text or "Label"
label.Text = props.Text or ""
label.Font = Enum.Font.RobotoMono
label.TextColor3 = Kurai_Lib.Theme.Text
label.TextSize = 16
label.TextXAlignment = props.Alignment or Enum.TextXAlignment.Left
label.TextYAlignment = Enum.TextYAlignment.Top
label.BackgroundTransparency = 1
label.Size = UDim2.new(1, -20, 0, 18)
label.LayoutOrder = #tab.Elements + 1
label.Parent = tab.Content
table.insert(tab.Elements, label)
local control = {
Instance = label,
SetText = function(text)
label.Text = text
return control
end,
GetText = function()
return label.Text
end
}
return control
end
function Kurai_Lib:_createSplitter(tabName, props)
props = props or {}
local tab = self.Tabs[tabName]
if not tab then return nil end
local splitter = Instance.new("Frame")
splitter.Name = props.Text or "Splitter"
splitter.BackgroundColor3 = Kurai_Lib.Theme.Accent
splitter.BorderSizePixel = 0
splitter.Size = UDim2.new(1, 0, 0, 1)
splitter.LayoutOrder = #tab.Elements + 1
splitter.Parent = tab.Content
table.insert(tab.Elements, splitter)
local control = {
Instance = splitter,
SetColor = function(color)
Kurai_Lib.Tween(splitter, {BackgroundColor3 = color})
return control
end,
GetColor = function()
return splitter.BackgroundColor3
end
}
return control
end
function Kurai_Lib:_createSlider(tabName, props, flag)
props = props or {}
local tab = self.Tabs[tabName]
if not tab then return nil end
local slider = Instance.new("Frame")
slider.Name = props.Text or "Slider"
slider.BackgroundTransparency = 1
slider.Size = UDim2.new(1, 0, 0, 50)
slider.LayoutOrder = #tab.Elements + 1
slider.Parent = tab.Content
local label = Instance.new("TextLabel")
label.Name = "Label"
label.Text = props.Text or "Slider"
label.Font = Enum.Font.RobotoMono
label.TextColor3 = Kurai_Lib.Theme.Text
label.TextSize = 16
label.TextXAlignment = Enum.TextXAlignment.Left
label.BackgroundTransparency = 1
label.Size = UDim2.new(1, 0, 0, 16)
label.Parent = slider
local labelPadding = Instance.new("UIPadding")
labelPadding.PaddingLeft = UDim.new(0, 2)
labelPadding.Parent = label
local valueLabel = Instance.new("TextLabel")
valueLabel.Name = "Value"
valueLabel.Text = props.State and tostring(props.State)..(props.Suffix or "") or "0"
valueLabel.Font = Enum.Font.RobotoMono
valueLabel.TextColor3 = Kurai_Lib.Theme.SubText
valueLabel.TextSize = 12
valueLabel.TextXAlignment = Enum.TextXAlignment.Right
valueLabel.BackgroundTransparency = 1
valueLabel.Position = UDim2.new(0, 0, 0, 16)
valueLabel.Size = UDim2.new(1, 0, 0, 16)
valueLabel.Parent = slider
local valuePadding = Instance.new("UIPadding")
valuePadding.PaddingLeft = UDim.new(0, 2)
valuePadding.Parent = valueLabel
local track = Instance.new("Frame")
track.Name = "Track"
track.BackgroundColor3 = Kurai_Lib.Theme.Content
track.BorderSizePixel = 0
track.Position = UDim2.new(0, 0, 0, 36)
track.Size = UDim2.new(1, 0, 0, 4)
track.Parent = slider
local trackCorner = Instance.new("UICorner")
trackCorner.CornerRadius = UDim.new(1, 0)
trackCorner.Parent = track
local fill = Instance.new("Frame")
fill.Name = "Fill"
fill.BackgroundColor3 = Kurai_Lib.Theme.Accent
fill.BorderSizePixel = 0
fill.Size = UDim2.new(0, 0, 1, 0)
fill.Parent = track
local fillCorner = Instance.new("UICorner")
fillCorner.CornerRadius = UDim.new(1, 0)
fillCorner.Parent = fill
local thumb = Instance.new("Frame")
thumb.Name = "Thumb"
thumb.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
thumb.BorderSizePixel = 0
thumb.Position = UDim2.new(0, 0, 0.5, -6)
thumb.Size = UDim2.new(0, 12, 0, 12)
thumb.Parent = track
local thumbCorner = Instance.new("UICorner")
thumbCorner.CornerRadius = UDim.new(1, 0)
thumbCorner.Parent = thumb
local min = props.Min or 0
local max = props.Max or 100
local increment = props.Increment or 1
local defaultValue = math.clamp(props.State or min, min, max)
local suffix = props.Suffix or ""
self.Flags = self.Flags or {}
self.Flags[flag or props.Text or "Slider"] = defaultValue
local value = defaultValue
local sliding = false
local function updateSlider(percent)
percent = math.clamp(percent, 0, 1)
value = math.floor(min + (max - min) * percent / increment) * increment
value = math.clamp(value, min, max)
local displayValue = props.Precise and string.format("%.2f", value) or tostring(value)
valueLabel.Text = displayValue..suffix
fill.Size = UDim2.new(percent, 0, 1, 0)
thumb.Position = UDim2.new(percent, -6, 0.5, -6)
self.Flags[flag or props.Text or "Slider"] = value
if props.Callback then
props.Callback(value, slider)
end
end
updateSlider((defaultValue - min) / (max - min))
local function updateValueFromInput(input)
local absoluteX = input.Position.X - track.AbsolutePosition.X
local percent = math.clamp(absoluteX / track.AbsoluteSize.X, 0, 1)
updateSlider(percent)
end
track.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
sliding = true
updateValueFromInput(input)
end
end)
track.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
sliding = false
end
end)
UserInputService.InputChanged:Connect(function(input)
if sliding and input.UserInputType == Enum.UserInputType.MouseMovement then
updateValueFromInput(input)
end
end)
table.insert(tab.Elements, slider)
local control = {
Instance = slider,
Set = function(self, newValue)
if type(self) ~= "table" and newValue == nil then
newValue = self
end
newValue = tonumber(newValue) or min
newValue = math.clamp(newValue, min, max)
updateSlider((newValue - min) / (max - min))
return control
end,
Get = function()
return value
end
}
return control
end
function Kurai_Lib:_createToggle(tabName, props, flag)
props = props or {}
local tab = self.Tabs[tabName]
if not tab then return nil end
local toggle = Instance.new("Frame")
toggle.Name = props.Text or "Toggle"
toggle.BackgroundTransparency = 1
toggle.Size = UDim2.new(1, 0, 0, 24)
toggle.LayoutOrder = #tab.Elements + 1
toggle.Parent = tab.Content
local label = Instance.new("TextLabel")
label.Name = "Label"
label.Text = props.Text or "Toggle"
label.Font = Enum.Font.RobotoMono
label.TextColor3 = Kurai_Lib.Theme.Text
label.TextSize = 16
label.TextXAlignment = Enum.TextXAlignment.Left
label.BackgroundTransparency = 1
label.Size = UDim2.new(1, -40, 1, 0)
label.Parent = toggle
local padding = Instance.new("UIPadding")
padding.PaddingLeft = UDim.new(0, 2)
padding.Parent = label
local toggleButton = Instance.new("TextButton")
toggleButton.Name = "ToggleButton"
toggleButton.Text = ""
toggleButton.AnchorPoint = Vector2.new(1, 0.5)
toggleButton.BackgroundColor3 = Kurai_Lib.Theme.Tab
toggleButton.Position = UDim2.new(1, 0, 0.5, 0)
toggleButton.Size = UDim2.new(0, 36, 0, 18)
toggleButton.Parent = toggle
local buttonCorner = Instance.new("UICorner")
buttonCorner.CornerRadius = UDim.new(1, 0)
buttonCorner.Parent = toggleButton
local dot = Instance.new("Frame")
dot.Name = "Dot"
dot.AnchorPoint = Vector2.new(0, 0.5)
dot.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
dot.Position = UDim2.new(0, 2, 0.5, 0)
dot.Size = UDim2.new(0, 16, 0, 16)
dot.Parent = toggleButton
local dotCorner = Instance.new("UICorner")
dotCorner.CornerRadius = UDim.new(1, 0)
dotCorner.Parent = dot
local state = props.State or false
self.Flags = self.Flags or {}
self.Flags[flag or props.Text or "Toggle"] = state
local function updateToggle()
if state then
Kurai_Lib.Tween(toggleButton, {BackgroundColor3 = Kurai_Lib.Theme.Accent})
Kurai_Lib.Tween(dot, {Position = UDim2.new(1, -18, 0.5, 0)})
else
Kurai_Lib.Tween(toggleButton, {BackgroundColor3 = Kurai_Lib.Theme.Tab})
Kurai_Lib.Tween(dot, {Position = UDim2.new(0, 2, 0.5, 0)})
end
end
updateToggle()
toggleButton.MouseButton1Click:Connect(function()
state = not state
self.Flags[flag or props.Text or "Toggle"] = state
updateToggle()
if props.Callback then
props.Callback(state, toggle)
end
end)
table.insert(tab.Elements, toggle)