Repository navigation
Expand file tree
/
Copy pathsource.lua
More file actions
4448 lines (3780 loc) · 186 KB
/
Copy pathsource.lua
File metadata and controls
4448 lines (3780 loc) · 186 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
--[[
Rayfield Interface Suite
by Sirius
shlex | Designing + Programming
iRay | Programming
Max | Programming
Damian | Programming
]]
-- Read first, so secure mode covers Rayfield's output from its first line.
local secureMode = false
if getgenv then
local ok, result = pcall(function() return getgenv().RAYFIELD_SECURE end)
if ok and result then secureMode = true end
end
-- Rayfield's own console output goes through these locals. Under secure mode they are silent.
-- They are never assigned as globals: in an executor those are shared with every other script.
local warn, print, error, assert = warn, print, error, assert
if secureMode then
local rawError = error
local rawAssert = assert
warn = function(...) end
print = function(...) end
error = function(_, level) rawError("", level) end
assert = function(v, ...) return rawAssert(v) end
end
if debugX then
warn('Initialising Rayfield')
end
local function getService(name)
local service = game:GetService(name)
return if cloneref then cloneref(service) else service
end
-- Remote modules are fetched from a fixed commit rather than a branch, so what runs is exactly what
-- was reviewed and a push to a branch can't change it under every running script. Bump this to
-- ship a new reporter or icon set. sirius-gate pins its reporter to the same commit.
local RAYFIELD_COMMIT = "38a84e32a7b91d873788b9da4deb020bfd87d182" -- SiriusSoftwareLtd/Rayfield: reporter.lua, icons.lua, sia.lua
local RAYFIELD_RAW = "https://raw.githubusercontent.com/SiriusSoftwareLtd/Rayfield/" .. RAYFIELD_COMMIT .. "/"
-- Services
local UserInputService = getService("UserInputService")
local TweenService = getService("TweenService")
local Players = getService("Players")
local CoreGui = getService("CoreGui")
-- Some executors have no task.cancel. Without it the thread is left to finish on its own.
local function cancelThread(thread: thread)
if task.cancel then
pcall(task.cancel, thread)
end
end
-- Loads and executes a function hosted on a remote URL. Cancels the request if the requested URL takes too long to respond.
-- Errors with the function are caught and logged to the output
local function loadWithTimeout(url: string, timeout: number?): ...any
assert(type(url) == "string", "Expected string, got " .. type(url))
timeout = timeout or 5
local requestCompleted = false
local success, result = false, nil
local requestThread = task.spawn(function()
local fetchSuccess, fetchResult = pcall(game.HttpGet, game, url) -- game:HttpGet(url)
-- If the request fails the content can be empty, even if fetchSuccess is true
if not fetchSuccess or #fetchResult == 0 then
if #fetchResult == 0 then
fetchResult = "Empty response" -- Set the error message
end
success, result = false, fetchResult
requestCompleted = true
return
end
local content = fetchResult -- Fetched content
local execSuccess, execResult = pcall(function()
return loadstring(content)()
end)
success, result = execSuccess, execResult
requestCompleted = true
end)
local timeoutThread = task.delay(timeout, function()
if not requestCompleted then
warn("Request for " .. url .. " timed out after " .. tostring(timeout) .. " seconds")
cancelThread(requestThread)
result = "Request timed out"
requestCompleted = true
end
end)
-- Wait for completion or timeout
while not requestCompleted do
task.wait()
end
-- Cancel timeout thread if still running when request completes
if coroutine.status(timeoutThread) ~= "dead" then
cancelThread(timeoutThread)
end
if not success then
warn("Failed to process " .. tostring(url) .. ": " .. tostring(result))
end
return if success then result else nil
end
local requestsDisabled = false
local analyticsOptOut = false -- the player set getgenv().RAYFIELD_ANALYTICS = false
local customAssetId = nil
if getgenv then
local ok, result = pcall(function() return getgenv().DISABLE_RAYFIELD_REQUESTS end)
if ok and result then requestsDisabled = true end
local ok2, result2 = pcall(function() return getgenv().RAYFIELD_ASSET_ID end)
if ok2 and type(result2) == "number" then customAssetId = result2 end
local ok3, result3 = pcall(function() return getgenv().RAYFIELD_ANALYTICS end)
if ok3 and result3 == false then analyticsOptOut = true end
end
local secureWarnings = {}
local customAssets = {}
local function secureNotify(wType, title, content)
if secureWarnings[wType] then return end
secureWarnings[wType] = true
task.spawn(function()
while not RayfieldLibrary or not RayfieldLibrary.Notify do task.wait(0.5) end
RayfieldLibrary:Notify({
Title = title,
Content = content,
Duration = 8,
})
end)
end
local InterfaceBuild = 'UU2NX'
local Release = "Build 1.760"
local RayfieldFolder = "Rayfield"
local ConfigurationFolder = RayfieldFolder.."/Configurations"
local ConfigurationExtension = ".rfld"
local settingsTable = {
General = {
-- if needs be in order just make getSetting(name)
rayfieldOpen = {Type = 'bind', Value = 'K', Name = 'Rayfield Keybind'},
-- buildwarnings
-- rayfieldprompts
},
System = {
usageAnalytics = {
Type = 'toggle',
Value = true,
Name = 'Usage analytics',
Description = 'Sends anonymous counts of which parts of this window are used. Never your name, what you type or your messages. sirius.menu/privacy',
},
}
}
-- Settings that have been overridden by the developer. These will not be saved to the user's configuration file
-- Overridden settings always take precedence over settings in the configuration file, and are cleared if the user changes the setting in the UI
local overriddenSettings: { [string]: any } = {} -- For example, overriddenSettings["System.rayfieldOpen"] = "J"
local function overrideSetting(category: string, name: string, value: any)
overriddenSettings[category .. "." .. name] = value
end
local function getSetting(category: string, name: string): any
if overriddenSettings[category .. "." .. name] ~= nil then
return overriddenSettings[category .. "." .. name]
elseif settingsTable[category][name] ~= nil then
return settingsTable[category][name].Value
end
end
-- If requests/analytics have been disabled by the developer or the player, set the user-facing
-- setting to false as well
if requestsDisabled or analyticsOptOut then
overrideSetting("System", "usageAnalytics", false)
end
local HttpService = getService('HttpService')
local RunService = getService('RunService')
-- Environment Check
local useStudio = RunService:IsStudio() or false
local settingsCreated = false
local settingsInitialized = false -- Whether the UI elements in the settings page have been set to the proper values
local requestFunc = (syn and syn.request) or (fluxus and fluxus.request) or (http and http.request) or http_request or request
-- The function below provides a safe alternative for calling error-prone functions
-- Especially useful for filesystem function (writefile, makefolder, etc.)
local function callSafely(func, ...)
if func then
local success, result = pcall(func, ...)
if not success then
warn("Rayfield | Function failed with error: ", result)
return false
else
return result
end
end
end
-- Ensures a folder exists by creating it if needed
local function ensureFolder(folderPath)
if isfolder and not callSafely(isfolder, folderPath) then
callSafely(makefolder, folderPath)
end
end
-- Folder and file names a hub supplies go into paths under the executor's workspace, so they can't
-- be allowed to climb out of it. Removing a character can expose a new "..", so ".:./" is cleaned
-- of the character first and the dots after, repeating until nothing changes.
local function stripTraversal(text: string): string
local previous
repeat
previous = text
text = string.gsub(text, "%.%.", "")
until text == previous
return text
end
-- Keeps "/" so a hub can still nest its folder, but never a leading one, a drive letter or "..".
local function sanitizeFolderName(value: any): string
local text = string.gsub(string.gsub(tostring(value), "\\", "/"), "[:%c]", "")
text = string.gsub(stripTraversal(text), "/+", "/")
return (string.gsub(text, "^/+", ""))
end
-- A single file name: no slashes of either kind, control characters or "..".
local function sanitizeFileName(value: any): string
local text = string.gsub(tostring(value), "[/\\%c]", "")
return stripTraversal(text)
end
local function loadSettings()
local file = nil
local success, result = pcall(function()
if callSafely(isfolder, RayfieldFolder) then
if callSafely(isfile, RayfieldFolder..'/settings'..ConfigurationExtension) then
file = callSafely(readfile, RayfieldFolder..'/settings'..ConfigurationExtension)
end
end
-- for debug in studio
if useStudio then
file = [[
{"General":{"rayfieldOpen":{"Value":"K","Type":"bind","Name":"Rayfield Keybind","Element":{"HoldToInteract":false,"Ext":true,"Name":"Rayfield Keybind","Set":null,"CallOnChange":true,"Callback":null,"CurrentKeybind":"K"}}},"System":{"usageAnalytics":{"Value":false,"Type":"toggle","Name":"Usage analytics","Element":{"Ext":true,"Name":"Usage analytics","Set":null,"CurrentValue":false,"Callback":null}}}}
]]
end
if file then
local decodeSuccess, decodedFile = pcall(function() return HttpService:JSONDecode(file) end)
if decodeSuccess then
file = decodedFile
else
file = {}
end
else
file = {}
end
if not settingsCreated then
return
end
-- Check if settings file has any entries
if next(file) ~= nil then
-- If it does, apply them
for categoryName, categoryTable in file do
for settingName, setting in categoryTable do
local default = settingsTable[categoryName] and settingsTable[categoryName][settingName]
if not default then continue end -- ignore keys not in settingsTable (old/renamed settings)
local settingType = typeof(default.Value)
-- Make sure setting has the correct type
if not (settingType == typeof(setting.Value)) then
warn("Rayfield | Error parsing settings file. '"..settingName.."' must be a "..settingType)
continue
end
default.Value = setting.Value
end
end
end
-- Apply the actual setting value to UI elements
for categoryName, categoryTable in settingsTable do
for settingName, setting in categoryTable do
if setting.Element then
setting.Element:Set(getSetting(categoryName, settingName))
end
end
end
settingsInitialized = true
end)
if not success then
if writefile then
warn('Rayfield had an issue accessing configuration saving capability.')
end
end
end
if debugX then
warn('Now Loading Settings Configuration')
end
loadSettings()
if debugX then
warn('Settings Loaded')
end
local ANALYTICS_TOKEN = "05de7f9fd320d3b8428cd1c77014a337b85b6c8efee2c5914f5ab5700c354b9a"
-- The reporter is fetched only at the moment it is about to be used, and only if the user hasn't
-- opted out and the developer hasn't set DISABLE_RAYFIELD_REQUESTS. Opting out means no request to
-- GitHub for it either, not just no event sent.
local reporter = nil
local reporterLoaded = false
local function loadReporter()
if reporterLoaded then return reporter end
reporterLoaded = true
if requestsDisabled or useStudio then return nil end
local fetchSuccess, fetchResult = pcall((game :: any).HttpGet, game, RAYFIELD_RAW .. "reporter.lua")
if fetchSuccess and #fetchResult > 0 then
local execSuccess, Analytics = pcall(function()
return (loadstring(fetchResult) :: any)()
end)
if execSuccess and Analytics then
pcall(function()
reporter = Analytics.new({
url = "https://rayfield-collect.sirius-software-ltd.workers.dev",
token = ANALYTICS_TOKEN,
product_name = "Rayfield",
category = "UILibrary",
})
end)
end
end
return reporter
end
-- Whether analytics may be sent right now. A saved opt-out is only known once the settings file has
-- been applied, so until then the answer is no; an executor that can't read files has nothing saved
-- to respect, so the default applies there, and getgenv().RAYFIELD_ANALYTICS = false is the
-- player's way to opt out.
local function analyticsAllowed(): boolean
if requestsDisabled or analyticsOptOut or useStudio then return false end
if not getSetting("System", "usageAnalytics") then return false end
return settingsInitialized or not (isfile and readfile)
end
-- SIA (sia.lua) counts which parts of a window players use. Like the reporter it is
-- fetched at the pinned commit, and only once analytics are allowed. It starts as a window is
-- created, before the key system and the settings page, so until the settings page has applied
-- the saved file, the file itself is read for an opt-out.
local SIA_TOKEN = "sia_rayfield_bd0f30653a58a75bac2987e3"
local sia = nil
local siaState = "off" -- "loading" while sia.lua is fetched, then "on"
local siaQueue = {} -- calls made while it loads, run in order once it has
local siaElements = {} -- every element made, registered whenever the client starts
local siaScript = nil -- the window's script details, kept for a restart from settings
local siaLoads = 0 -- counts starts, so a load the player cancelled and restarted gives way
local function savedAnalyticsChoice(): boolean?
local ok, value = pcall(function()
local path = RayfieldFolder .. "/settings" .. ConfigurationExtension
if not (isfile and readfile and isfile(path)) then return nil end
return HttpService:JSONDecode(readfile(path)).System.usageAnalytics.Value
end)
return if ok and type(value) == "boolean" then value else nil
end
local function siaAllowed(): boolean
if requestsDisabled or analyticsOptOut or useStudio then return false end
if not getSetting("System", "usageAnalytics") then return false end
return settingsInitialized or savedAnalyticsChoice() ~= false
end
-- Runs fn(client) now, after the client loads, or not at all when SIA is off.
local function siaRun(fn: (any) -> ())
if siaState == "on" and sia then
pcall(fn, sia)
elseif siaState == "loading" and #siaQueue < 500 then
table.insert(siaQueue, fn)
end
end
local function siaId(client: any, handle: any): string?
handle.id = handle.id or client:element(handle.kind, handle.name, handle.tab)
return handle.id
end
local function siaStart(info: { name: string?, id: any?, token: any?, theme: string? })
siaScript = info
if siaState ~= "off" or not siaAllowed() then return end
siaState = "loading"
siaLoads += 1
local load = siaLoads
task.spawn(function()
local client = nil
local fetched, source = pcall((game :: any).HttpGet, game, RAYFIELD_RAW .. "sia.lua")
if fetched and type(source) == "string" and #source > 0 then
pcall(function()
local SIA = (loadstring(source) :: any)()
client = SIA.new({ token = SIA_TOKEN, lib = "gen1", libVersion = Release, script = info, theme = info.theme })
end)
end
-- the player may have turned it off while it loaded
if load ~= siaLoads then return end
if not client or siaState ~= "loading" then
siaState, siaQueue = "off", {}
return
end
sia, siaState = client, "on"
for _, handle in siaElements do
pcall(function()
local id = siaId(client, handle)
if handle.value then client:state(id, handle.value) end
end)
end
local queued = siaQueue
siaQueue = {}
for _, fn in queued do
pcall(fn, client)
end
end)
end
local function siaStop()
if sia then pcall(sia.disable, sia) end
sia, siaState, siaQueue = nil, "off", {}
end
local siaCurrentTab = nil -- the tab on show, whose elements count as seen as they're made
-- An element's handle, for siaUsed, siaSetState and siaError. The settings page is tab 0,
-- which is Rayfield's, not the script's. Labels stay on this side: the client sends a category
-- worked out from them.
local function siaElement(kind: string, name: any, tab: number?): any
-- The Rayfield Settings page (no tab number) is tab 0: SIA keeps it apart from the script's tabs.
tab = tab or 0
local handle = { kind = kind, name = tostring(name), tab = tab }
table.insert(siaElements, handle)
siaRun(function(client)
siaId(client, handle)
if tab == siaCurrentTab then client:tab(tab) end
end)
return handle
end
-- A player used the element. value is 0..1 where the element has one.
local function siaUsed(handle: any, action: string, value: number?)
if not handle then return end
siaRun(function(client) client:used(siaId(client, handle), action, value) end)
end
-- The element's value, from the player or the script: toggles 1 or 0, sliders 0..1.
local function siaSetState(handle: any, value: number)
if not handle then return end
handle.value = value -- for a client that starts later
siaRun(function(client) client:state(siaId(client, handle), value) end)
end
local function siaError(handle: any)
if not handle then return end
siaRun(function(client) client:error(siaId(client, handle)) end)
end
local function siaCall(method: string, ...: any)
local args = table.pack(...)
siaRun(function(client) client[method](client, table.unpack(args, 1, args.n)) end)
end
if debugX then
warn('Moving on to continue initialisation')
end
local RayfieldLibrary = {
Flags = {},
Theme = {
Default = {
TextColor = Color3.fromRGB(240, 240, 240),
Background = Color3.fromRGB(25, 25, 25),
Topbar = Color3.fromRGB(34, 34, 34),
Shadow = Color3.fromRGB(20, 20, 20),
NotificationBackground = Color3.fromRGB(20, 20, 20),
NotificationActionsBackground = Color3.fromRGB(230, 230, 230),
TabBackground = Color3.fromRGB(80, 80, 80),
TabStroke = Color3.fromRGB(85, 85, 85),
TabBackgroundSelected = Color3.fromRGB(210, 210, 210),
TabTextColor = Color3.fromRGB(240, 240, 240),
SelectedTabTextColor = Color3.fromRGB(50, 50, 50),
ElementBackground = Color3.fromRGB(35, 35, 35),
ElementBackgroundHover = Color3.fromRGB(40, 40, 40),
SecondaryElementBackground = Color3.fromRGB(25, 25, 25),
ElementStroke = Color3.fromRGB(50, 50, 50),
SecondaryElementStroke = Color3.fromRGB(40, 40, 40),
SliderBackground = Color3.fromRGB(50, 138, 220),
SliderProgress = Color3.fromRGB(50, 138, 220),
SliderStroke = Color3.fromRGB(58, 163, 255),
ToggleBackground = Color3.fromRGB(30, 30, 30),
ToggleEnabled = Color3.fromRGB(0, 146, 214),
ToggleDisabled = Color3.fromRGB(100, 100, 100),
ToggleEnabledStroke = Color3.fromRGB(0, 170, 255),
ToggleDisabledStroke = Color3.fromRGB(125, 125, 125),
ToggleEnabledOuterStroke = Color3.fromRGB(100, 100, 100),
ToggleDisabledOuterStroke = Color3.fromRGB(65, 65, 65),
DropdownSelected = Color3.fromRGB(40, 40, 40),
DropdownUnselected = Color3.fromRGB(30, 30, 30),
InputBackground = Color3.fromRGB(30, 30, 30),
InputStroke = Color3.fromRGB(65, 65, 65),
PlaceholderColor = Color3.fromRGB(178, 178, 178)
},
Ocean = {
TextColor = Color3.fromRGB(230, 240, 240),
Background = Color3.fromRGB(20, 30, 30),
Topbar = Color3.fromRGB(25, 40, 40),
Shadow = Color3.fromRGB(15, 20, 20),
NotificationBackground = Color3.fromRGB(25, 35, 35),
NotificationActionsBackground = Color3.fromRGB(230, 240, 240),
TabBackground = Color3.fromRGB(40, 60, 60),
TabStroke = Color3.fromRGB(50, 70, 70),
TabBackgroundSelected = Color3.fromRGB(100, 180, 180),
TabTextColor = Color3.fromRGB(210, 230, 230),
SelectedTabTextColor = Color3.fromRGB(20, 50, 50),
ElementBackground = Color3.fromRGB(30, 50, 50),
ElementBackgroundHover = Color3.fromRGB(40, 60, 60),
SecondaryElementBackground = Color3.fromRGB(30, 45, 45),
ElementStroke = Color3.fromRGB(45, 70, 70),
SecondaryElementStroke = Color3.fromRGB(40, 65, 65),
SliderBackground = Color3.fromRGB(0, 110, 110),
SliderProgress = Color3.fromRGB(0, 140, 140),
SliderStroke = Color3.fromRGB(0, 160, 160),
ToggleBackground = Color3.fromRGB(30, 50, 50),
ToggleEnabled = Color3.fromRGB(0, 130, 130),
ToggleDisabled = Color3.fromRGB(70, 90, 90),
ToggleEnabledStroke = Color3.fromRGB(0, 160, 160),
ToggleDisabledStroke = Color3.fromRGB(85, 105, 105),
ToggleEnabledOuterStroke = Color3.fromRGB(50, 100, 100),
ToggleDisabledOuterStroke = Color3.fromRGB(45, 65, 65),
DropdownSelected = Color3.fromRGB(30, 60, 60),
DropdownUnselected = Color3.fromRGB(25, 40, 40),
InputBackground = Color3.fromRGB(30, 50, 50),
InputStroke = Color3.fromRGB(50, 70, 70),
PlaceholderColor = Color3.fromRGB(140, 160, 160)
},
AmberGlow = {
TextColor = Color3.fromRGB(255, 245, 230),
Background = Color3.fromRGB(45, 30, 20),
Topbar = Color3.fromRGB(55, 40, 25),
Shadow = Color3.fromRGB(35, 25, 15),
NotificationBackground = Color3.fromRGB(50, 35, 25),
NotificationActionsBackground = Color3.fromRGB(245, 230, 215),
TabBackground = Color3.fromRGB(75, 50, 35),
TabStroke = Color3.fromRGB(90, 60, 45),
TabBackgroundSelected = Color3.fromRGB(230, 180, 100),
TabTextColor = Color3.fromRGB(250, 220, 200),
SelectedTabTextColor = Color3.fromRGB(50, 30, 10),
ElementBackground = Color3.fromRGB(60, 45, 35),
ElementBackgroundHover = Color3.fromRGB(70, 50, 40),
SecondaryElementBackground = Color3.fromRGB(55, 40, 30),
ElementStroke = Color3.fromRGB(85, 60, 45),
SecondaryElementStroke = Color3.fromRGB(75, 50, 35),
SliderBackground = Color3.fromRGB(220, 130, 60),
SliderProgress = Color3.fromRGB(250, 150, 75),
SliderStroke = Color3.fromRGB(255, 170, 85),
ToggleBackground = Color3.fromRGB(55, 40, 30),
ToggleEnabled = Color3.fromRGB(240, 130, 30),
ToggleDisabled = Color3.fromRGB(90, 70, 60),
ToggleEnabledStroke = Color3.fromRGB(255, 160, 50),
ToggleDisabledStroke = Color3.fromRGB(110, 85, 75),
ToggleEnabledOuterStroke = Color3.fromRGB(200, 100, 50),
ToggleDisabledOuterStroke = Color3.fromRGB(75, 60, 55),
DropdownSelected = Color3.fromRGB(70, 50, 40),
DropdownUnselected = Color3.fromRGB(55, 40, 30),
InputBackground = Color3.fromRGB(60, 45, 35),
InputStroke = Color3.fromRGB(90, 65, 50),
PlaceholderColor = Color3.fromRGB(190, 150, 130)
},
Light = {
TextColor = Color3.fromRGB(40, 40, 40),
Background = Color3.fromRGB(245, 245, 245),
Topbar = Color3.fromRGB(230, 230, 230),
Shadow = Color3.fromRGB(200, 200, 200),
NotificationBackground = Color3.fromRGB(250, 250, 250),
NotificationActionsBackground = Color3.fromRGB(240, 240, 240),
TabBackground = Color3.fromRGB(235, 235, 235),
TabStroke = Color3.fromRGB(215, 215, 215),
TabBackgroundSelected = Color3.fromRGB(255, 255, 255),
TabTextColor = Color3.fromRGB(80, 80, 80),
SelectedTabTextColor = Color3.fromRGB(0, 0, 0),
ElementBackground = Color3.fromRGB(240, 240, 240),
ElementBackgroundHover = Color3.fromRGB(225, 225, 225),
SecondaryElementBackground = Color3.fromRGB(235, 235, 235),
ElementStroke = Color3.fromRGB(210, 210, 210),
SecondaryElementStroke = Color3.fromRGB(210, 210, 210),
SliderBackground = Color3.fromRGB(150, 180, 220),
SliderProgress = Color3.fromRGB(100, 150, 200),
SliderStroke = Color3.fromRGB(120, 170, 220),
ToggleBackground = Color3.fromRGB(220, 220, 220),
ToggleEnabled = Color3.fromRGB(0, 146, 214),
ToggleDisabled = Color3.fromRGB(150, 150, 150),
ToggleEnabledStroke = Color3.fromRGB(0, 170, 255),
ToggleDisabledStroke = Color3.fromRGB(170, 170, 170),
ToggleEnabledOuterStroke = Color3.fromRGB(100, 100, 100),
ToggleDisabledOuterStroke = Color3.fromRGB(180, 180, 180),
DropdownSelected = Color3.fromRGB(230, 230, 230),
DropdownUnselected = Color3.fromRGB(220, 220, 220),
InputBackground = Color3.fromRGB(240, 240, 240),
InputStroke = Color3.fromRGB(180, 180, 180),
PlaceholderColor = Color3.fromRGB(140, 140, 140)
},
Amethyst = {
TextColor = Color3.fromRGB(240, 240, 240),
Background = Color3.fromRGB(30, 20, 40),
Topbar = Color3.fromRGB(40, 25, 50),
Shadow = Color3.fromRGB(20, 15, 30),
NotificationBackground = Color3.fromRGB(35, 20, 40),
NotificationActionsBackground = Color3.fromRGB(240, 240, 250),
TabBackground = Color3.fromRGB(60, 40, 80),
TabStroke = Color3.fromRGB(70, 45, 90),
TabBackgroundSelected = Color3.fromRGB(180, 140, 200),
TabTextColor = Color3.fromRGB(230, 230, 240),
SelectedTabTextColor = Color3.fromRGB(50, 20, 50),
ElementBackground = Color3.fromRGB(45, 30, 60),
ElementBackgroundHover = Color3.fromRGB(50, 35, 70),
SecondaryElementBackground = Color3.fromRGB(40, 30, 55),
ElementStroke = Color3.fromRGB(70, 50, 85),
SecondaryElementStroke = Color3.fromRGB(65, 45, 80),
SliderBackground = Color3.fromRGB(100, 60, 150),
SliderProgress = Color3.fromRGB(130, 80, 180),
SliderStroke = Color3.fromRGB(150, 100, 200),
ToggleBackground = Color3.fromRGB(45, 30, 55),
ToggleEnabled = Color3.fromRGB(120, 60, 150),
ToggleDisabled = Color3.fromRGB(94, 47, 117),
ToggleEnabledStroke = Color3.fromRGB(140, 80, 170),
ToggleDisabledStroke = Color3.fromRGB(124, 71, 150),
ToggleEnabledOuterStroke = Color3.fromRGB(90, 40, 120),
ToggleDisabledOuterStroke = Color3.fromRGB(80, 50, 110),
DropdownSelected = Color3.fromRGB(50, 35, 70),
DropdownUnselected = Color3.fromRGB(35, 25, 50),
InputBackground = Color3.fromRGB(45, 30, 60),
InputStroke = Color3.fromRGB(80, 50, 110),
PlaceholderColor = Color3.fromRGB(178, 150, 200)
},
Green = {
TextColor = Color3.fromRGB(30, 60, 30),
Background = Color3.fromRGB(235, 245, 235),
Topbar = Color3.fromRGB(210, 230, 210),
Shadow = Color3.fromRGB(200, 220, 200),
NotificationBackground = Color3.fromRGB(240, 250, 240),
NotificationActionsBackground = Color3.fromRGB(220, 235, 220),
TabBackground = Color3.fromRGB(215, 235, 215),
TabStroke = Color3.fromRGB(190, 210, 190),
TabBackgroundSelected = Color3.fromRGB(245, 255, 245),
TabTextColor = Color3.fromRGB(50, 80, 50),
SelectedTabTextColor = Color3.fromRGB(20, 60, 20),
ElementBackground = Color3.fromRGB(225, 240, 225),
ElementBackgroundHover = Color3.fromRGB(210, 225, 210),
SecondaryElementBackground = Color3.fromRGB(235, 245, 235),
ElementStroke = Color3.fromRGB(180, 200, 180),
SecondaryElementStroke = Color3.fromRGB(180, 200, 180),
SliderBackground = Color3.fromRGB(90, 160, 90),
SliderProgress = Color3.fromRGB(70, 130, 70),
SliderStroke = Color3.fromRGB(100, 180, 100),
ToggleBackground = Color3.fromRGB(215, 235, 215),
ToggleEnabled = Color3.fromRGB(60, 130, 60),
ToggleDisabled = Color3.fromRGB(150, 175, 150),
ToggleEnabledStroke = Color3.fromRGB(80, 150, 80),
ToggleDisabledStroke = Color3.fromRGB(130, 150, 130),
ToggleEnabledOuterStroke = Color3.fromRGB(100, 160, 100),
ToggleDisabledOuterStroke = Color3.fromRGB(160, 180, 160),
DropdownSelected = Color3.fromRGB(225, 240, 225),
DropdownUnselected = Color3.fromRGB(210, 225, 210),
InputBackground = Color3.fromRGB(235, 245, 235),
InputStroke = Color3.fromRGB(180, 200, 180),
PlaceholderColor = Color3.fromRGB(120, 140, 120)
},
Bloom = {
TextColor = Color3.fromRGB(60, 40, 50),
Background = Color3.fromRGB(255, 240, 245),
Topbar = Color3.fromRGB(250, 220, 225),
Shadow = Color3.fromRGB(230, 190, 195),
NotificationBackground = Color3.fromRGB(255, 235, 240),
NotificationActionsBackground = Color3.fromRGB(245, 215, 225),
TabBackground = Color3.fromRGB(240, 210, 220),
TabStroke = Color3.fromRGB(230, 200, 210),
TabBackgroundSelected = Color3.fromRGB(255, 225, 235),
TabTextColor = Color3.fromRGB(80, 40, 60),
SelectedTabTextColor = Color3.fromRGB(50, 30, 50),
ElementBackground = Color3.fromRGB(255, 235, 240),
ElementBackgroundHover = Color3.fromRGB(245, 220, 230),
SecondaryElementBackground = Color3.fromRGB(255, 235, 240),
ElementStroke = Color3.fromRGB(230, 200, 210),
SecondaryElementStroke = Color3.fromRGB(230, 200, 210),
SliderBackground = Color3.fromRGB(240, 130, 160),
SliderProgress = Color3.fromRGB(250, 160, 180),
SliderStroke = Color3.fromRGB(255, 180, 200),
ToggleBackground = Color3.fromRGB(240, 210, 220),
ToggleEnabled = Color3.fromRGB(255, 140, 170),
ToggleDisabled = Color3.fromRGB(200, 180, 185),
ToggleEnabledStroke = Color3.fromRGB(250, 160, 190),
ToggleDisabledStroke = Color3.fromRGB(210, 180, 190),
ToggleEnabledOuterStroke = Color3.fromRGB(220, 160, 180),
ToggleDisabledOuterStroke = Color3.fromRGB(190, 170, 180),
DropdownSelected = Color3.fromRGB(250, 220, 225),
DropdownUnselected = Color3.fromRGB(240, 210, 220),
InputBackground = Color3.fromRGB(255, 235, 240),
InputStroke = Color3.fromRGB(220, 190, 200),
PlaceholderColor = Color3.fromRGB(170, 130, 140)
},
DarkBlue = {
TextColor = Color3.fromRGB(230, 230, 230),
Background = Color3.fromRGB(20, 25, 30),
Topbar = Color3.fromRGB(30, 35, 40),
Shadow = Color3.fromRGB(15, 20, 25),
NotificationBackground = Color3.fromRGB(25, 30, 35),
NotificationActionsBackground = Color3.fromRGB(45, 50, 55),
TabBackground = Color3.fromRGB(35, 40, 45),
TabStroke = Color3.fromRGB(45, 50, 60),
TabBackgroundSelected = Color3.fromRGB(40, 70, 100),
TabTextColor = Color3.fromRGB(200, 200, 200),
SelectedTabTextColor = Color3.fromRGB(255, 255, 255),
ElementBackground = Color3.fromRGB(30, 35, 40),
ElementBackgroundHover = Color3.fromRGB(40, 45, 50),
SecondaryElementBackground = Color3.fromRGB(35, 40, 45),
ElementStroke = Color3.fromRGB(45, 50, 60),
SecondaryElementStroke = Color3.fromRGB(40, 45, 55),
SliderBackground = Color3.fromRGB(0, 90, 180),
SliderProgress = Color3.fromRGB(0, 120, 210),
SliderStroke = Color3.fromRGB(0, 150, 240),
ToggleBackground = Color3.fromRGB(35, 40, 45),
ToggleEnabled = Color3.fromRGB(0, 120, 210),
ToggleDisabled = Color3.fromRGB(70, 70, 80),
ToggleEnabledStroke = Color3.fromRGB(0, 150, 240),
ToggleDisabledStroke = Color3.fromRGB(75, 75, 85),
ToggleEnabledOuterStroke = Color3.fromRGB(20, 100, 180),
ToggleDisabledOuterStroke = Color3.fromRGB(55, 55, 65),
DropdownSelected = Color3.fromRGB(30, 70, 90),
DropdownUnselected = Color3.fromRGB(25, 30, 35),
InputBackground = Color3.fromRGB(25, 30, 35),
InputStroke = Color3.fromRGB(45, 50, 60),
PlaceholderColor = Color3.fromRGB(150, 150, 160)
},
Serenity = {
TextColor = Color3.fromRGB(50, 55, 60),
Background = Color3.fromRGB(240, 245, 250),
Topbar = Color3.fromRGB(215, 225, 235),
Shadow = Color3.fromRGB(200, 210, 220),
NotificationBackground = Color3.fromRGB(210, 220, 230),
NotificationActionsBackground = Color3.fromRGB(225, 230, 240),
TabBackground = Color3.fromRGB(200, 210, 220),
TabStroke = Color3.fromRGB(180, 190, 200),
TabBackgroundSelected = Color3.fromRGB(175, 185, 200),
TabTextColor = Color3.fromRGB(50, 55, 60),
SelectedTabTextColor = Color3.fromRGB(30, 35, 40),
ElementBackground = Color3.fromRGB(210, 220, 230),
ElementBackgroundHover = Color3.fromRGB(220, 230, 240),
SecondaryElementBackground = Color3.fromRGB(200, 210, 220),
ElementStroke = Color3.fromRGB(190, 200, 210),
SecondaryElementStroke = Color3.fromRGB(180, 190, 200),
SliderBackground = Color3.fromRGB(200, 220, 235), -- Lighter shade
SliderProgress = Color3.fromRGB(70, 130, 180),
SliderStroke = Color3.fromRGB(150, 180, 220),
ToggleBackground = Color3.fromRGB(210, 220, 230),
ToggleEnabled = Color3.fromRGB(70, 160, 210),
ToggleDisabled = Color3.fromRGB(180, 180, 180),
ToggleEnabledStroke = Color3.fromRGB(60, 150, 200),
ToggleDisabledStroke = Color3.fromRGB(140, 140, 140),
ToggleEnabledOuterStroke = Color3.fromRGB(100, 120, 140),
ToggleDisabledOuterStroke = Color3.fromRGB(120, 120, 130),
DropdownSelected = Color3.fromRGB(220, 230, 240),
DropdownUnselected = Color3.fromRGB(200, 210, 220),
InputBackground = Color3.fromRGB(220, 230, 240),
InputStroke = Color3.fromRGB(180, 190, 200),
PlaceholderColor = Color3.fromRGB(150, 150, 150)
},
}
}
-- Interface Management
local RayfieldAssetId = customAssetId or 10804731440
local Rayfield = useStudio and script.Parent:FindFirstChild('Rayfield') or game:GetObjects("rbxassetid://"..RayfieldAssetId)[1]
local buildAttempts = 0
local correctBuild = false
local warned
local globalLoaded
local rayfieldDestroyed = false -- True when RayfieldLibrary:Destroy() is called
repeat
if Rayfield:FindFirstChild('Build') and Rayfield.Build.Value == InterfaceBuild then
correctBuild = true
break
end
correctBuild = false
if not warned then
warn('Rayfield | Build Mismatch')
print('Rayfield may encounter issues as you are running an incompatible interface version ('.. ((Rayfield:FindFirstChild('Build') and Rayfield.Build.Value) or 'No Build') ..').\n\nThis version of Rayfield is intended for interface build '..InterfaceBuild..'.')
warned = true
end
local toDestroy
toDestroy, Rayfield = Rayfield, useStudio and script.Parent:FindFirstChild('Rayfield') or game:GetObjects("rbxassetid://"..RayfieldAssetId)[1]
if toDestroy and not useStudio then toDestroy:Destroy() end
buildAttempts = buildAttempts + 1
until buildAttempts >= 2
Rayfield.Enabled = false
if gethui then
Rayfield.Parent = gethui()
elseif syn and syn.protect_gui then
syn.protect_gui(Rayfield)
Rayfield.Parent = CoreGui
elseif not useStudio and CoreGui:FindFirstChild("RobloxGui") then
Rayfield.Parent = CoreGui:FindFirstChild("RobloxGui")
elseif not useStudio then
Rayfield.Parent = CoreGui
end
-- Running a script again loads a second copy of Rayfield. The copy it replaces is torn down through
-- this event, which calls its Destroy: that removes its interface and disconnects its input
-- listeners, which would otherwise keep answering hotkeys for a window nobody can see. Builds
-- before 1.753 have no event, so those are only hidden and renamed, as before.
local TEARDOWN_EVENT = "RayfieldTeardown"
local function retireInterface(Interface: any)
Interface.Enabled = false
Interface.Name = "Rayfield-Old"
local teardown = Interface:FindFirstChild(TEARDOWN_EVENT)
if teardown and teardown:IsA("BindableEvent") then
pcall(function()
teardown:Fire()
end)
end
end
if gethui then
for _, Interface in ipairs(gethui():GetChildren()) do
if Interface.Name == Rayfield.Name and Interface ~= Rayfield then
retireInterface(Interface)
end
end
elseif not useStudio then
for _, Interface in ipairs(CoreGui:GetChildren()) do
if Interface.Name == Rayfield.Name and Interface ~= Rayfield then
retireInterface(Interface)
end
end
end
do
local teardown = Instance.new("BindableEvent")
teardown.Name = TEARDOWN_EVENT
teardown.Event:Connect(function()
if not rayfieldDestroyed and type(RayfieldLibrary.Destroy) == "function" then
RayfieldLibrary:Destroy()
end
end)
teardown.Parent = Rayfield
end
if secureMode and not customAssetId then
secureNotify("default_asset", "Secure Mode", "You are using the default Rayfield asset ID. Set RAYFIELD_ASSET_ID to a custom upload to avoid detection.")
end
do
local AssetPath = RayfieldFolder.."/Assets"
local AssetBaseURL = "https://github.com/SiriusSoftwareLtd/Rayfield/blob/main/assets/"
local assetFiles = {
["111263549366178"] = AssetBaseURL.."111263549366178.png?raw=true",
["77891951053543"] = AssetBaseURL.."77891951053543.png?raw=true",
["78137979054938"] = AssetBaseURL.."78137979054938.png?raw=true",
["80503127983237"] = AssetBaseURL.."80503127983237.png?raw=true",
["10137832201"] = AssetBaseURL.."10137832201.png?raw=true",
["10137941941"] = AssetBaseURL.."10137941941.png?raw=true",
["11036884234"] = AssetBaseURL.."11036884234.png?raw=true",
["11413591840"] = AssetBaseURL.."11413591840.png?raw=true",
["11745872910"] = AssetBaseURL.."11745872910.png?raw=true",
["12577727209"] = AssetBaseURL.."12577727209.png?raw=true",
["18458939117"] = AssetBaseURL.."18458939117.png?raw=true",
["3259050989"] = AssetBaseURL.."3259050989.png?raw=true",
["3523728077"] = AssetBaseURL.."3523728077.png?raw=true",
["3602733521"] = AssetBaseURL.."3602733521.png?raw=true",
["IconChevronTopMedium"] = AssetBaseURL.."IconChevronTopMedium.png?raw=true",
["4483362458"] = AssetBaseURL.."4483362458.png?raw=true",
["5587865193"] = AssetBaseURL.."5587865193.png?raw=true",
["IconMagnifyingGlass2"] = AssetBaseURL.."IconMagnifyingGlass2.png?raw=true",
}
for id, _ in assetFiles do
customAssets[tostring(id)] = ""
end
local hasCustomAsset = type(getcustomasset) == "function"
local hasFilesystem = type(writefile) == "function" and type(makefolder) == "function" and type(isfile) == "function" and type(isfolder) == "function"
if hasCustomAsset and hasFilesystem then
local ok, err = pcall(function()
ensureFolder(RayfieldFolder)
ensureFolder(AssetPath)
-- skip ids we've already tried so a dead asset can't loop the loader forever
local attempted = {}
local function nextToFetch()