File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11local ChangeHistoryService = game :GetService (" ChangeHistoryService" )
2+ local CollectionService = game :GetService (" CollectionService" )
23local ServerStorage = game :GetService (" ServerStorage" )
34local Lighting = game :GetService (" Lighting" )
45
@@ -31,6 +32,29 @@ local function createProfile()
3132 return profileFolder
3233end
3334
35+ local function determineParent ()
36+ local parentCounts = {}
37+
38+ for _ , profile in CollectionService :GetTagged (" LightingProfile" ) do
39+ if not parentCounts [profile .Parent ] then
40+ parentCounts [profile .Parent ] = 1
41+ else
42+ parentCounts [profile .Parent ] += 1
43+ end
44+ end
45+
46+ local highestCount = 0
47+ local commonParent = ServerStorage
48+
49+ for parent , count in parentCounts do
50+ if count > highestCount then
51+ commonParent = parent
52+ end
53+ end
54+
55+ return commonParent
56+ end
57+
3458return function (props )
3559 local textBox = props .textBoxRef :getValue ()
3660
@@ -53,7 +77,7 @@ return function(props)
5377 local profile = createProfile ()
5478 profile .Name = profileName
5579 profile :AddTag (" LightingProfile" )
56- profile .Parent = ServerStorage
80+ profile .Parent = determineParent ()
5781
5882 ChangeHistoryService :SetWaypoint (" Create lighting profile" )
5983 end ,
You can’t perform that action at this time.
0 commit comments