From 298fdceff598d24f622c5bc41817b9f57013a90e Mon Sep 17 00:00:00 2001 From: Ricardo Loureiro Date: Fri, 18 Feb 2022 00:13:34 +0000 Subject: [PATCH 1/5] Update Overture.module.lua --- Overture.module.lua | 293 ++++++++++++++++++++++++++++---------------- 1 file changed, 185 insertions(+), 108 deletions(-) diff --git a/Overture.module.lua b/Overture.module.lua index 7841e9f..0fe1a19 100644 --- a/Overture.module.lua +++ b/Overture.module.lua @@ -1,152 +1,229 @@ +--!nonstrict --// Initialization local RunService = game:GetService("RunService") local PlayerService = game:GetService("Players") local StarterPlayer = game:GetService("StarterPlayer") local CollectionService = game:GetService("CollectionService") -local ReplicatedStorage = game:GetService("ReplicatedStorage") -local ServerScriptService = game:GetService("ServerScriptService") -local IsClient = RunService:IsClient() -local IsServer = RunService:IsServer() +local OvertureYield = script:WaitForChild("OvertureYield") +local oStarterPlayerScripts = script:WaitForChild("StarterPlayerScripts"):: Folder +local oStarterCharacterScripts = script:WaitForChild("StarterCharacterScripts"):: Folder +local StarterCharacterScripts = StarterPlayer:WaitForChild("StarterCharacterScripts"):: Folder local Module = {} -local CollectionMetatable = {} - ---// Variables - -local DebugPrint = false - -local RetrievalSets = { - ["RemoteEvent"] = "RemoteEvent", - ["RemoteFunction"] = "RemoteFunction", - ["BindableEvent"] = "BindableEvent", - ["BindableFunction"] = "BindableFunction", -} +local LibraryThreadCache: {[thread]: string} = {} +local Libraries: {[string]: ModuleScript} = {} --// Functions -local function printd(...) - if DebugPrint then - return print(...) +local function Reparent(Child, NewParent) + if Child:IsA("LocalScript") and not Child.Disabled then + Child:SetAttribute("EnableOnceReady", true) + Child.Disabled = true end + + Child.Parent = NewParent end -local function Retrieve(InstanceName, InstanceClass, InstanceParent) - --/ Finds an Instance by name and creates a new one if it doesen't exist - - local SearchInstance = nil - local InstanceCreated = false - - if InstanceParent:FindFirstChild(InstanceName) then - SearchInstance = InstanceParent[InstanceName] - else - InstanceCreated = true +local function Retrieve(InstanceName: string, InstanceClass: string, InstanceParent: Instance, ForceWait: boolean?): Instance + if ForceWait then + return InstanceParent:WaitForChild(InstanceName) + end + + local SearchInstance = InstanceParent:FindFirstChild(InstanceName) + + if not SearchInstance then SearchInstance = Instance.new(InstanceClass) SearchInstance.Name = InstanceName SearchInstance.Parent = InstanceParent end - - return SearchInstance, InstanceCreated + + return SearchInstance end -local function BindToTag(Tag, Callback) - CollectionService:GetInstanceAddedSignal(Tag):Connect(Callback) - - for _, TaggedItem in next, CollectionService:GetTagged(Tag) do - Callback(TaggedItem) +function Module._BindFunction(Function: (Instance) -> (), Event: RBXScriptSignal, Existing: {Instance}): RBXScriptConnection + if Existing then + for _, Value in next, Existing do + task.spawn(Function, Value) + end end + + return Event:Connect(Function) +end + +function Module._BindToTag(Tag: string, Function: (Instance) -> ()) + return Module._BindFunction(Function, CollectionService:GetInstanceAddedSignal(Tag), CollectionService:GetTagged(Tag)) end -function CollectionMetatable:__newindex(Index, Value) - rawset(self, Index, Value) - if Index:sub(1, 1) == "_" then return end - - for BindableEvent, ExpectedIndex in next, self._WaitCache do - if Index == ExpectedIndex then - spawn(function() - BindableEvent:Fire(Value) - BindableEvent:Destroy() - end) +function Module._CountLibrariesIn(Parent: Instance, CountLocally: boolean?): number + local StoredCount = Parent:GetAttribute("LibrariesIn") + + if StoredCount then + return StoredCount + end + + if RunService:IsClient() and not CountLocally then + return OvertureYield:InvokeServer(Parent) + else + local Count = 0 + + for _, Descendant in next, Parent:GetDescendants() do + if Descendant:IsA("ModuleScript") then + Count += 1 + end + end + + if RunService:IsServer() then + Parent:SetAttribute("LibrariesIn", Count) end + + return Count end end -do Module.Libraries = setmetatable({}, CollectionMetatable) - Module.Libraries._Folder = Retrieve("Libraries", "Folder", ReplicatedStorage) - Module.Libraries._WaitCache = {} - - BindToTag("oLibrary", function(Object) - Module.Libraries[Object.Name] = Object - - if CollectionService:HasTag(Object, "ForceReplicate") then - Object.Parent = Module.Libraries._Folder +function Module:_LoadServer() + if script:GetAttribute("ServerLoaded") then + return warn("Attempted to load Overture multiple times.") + else + script:SetAttribute("ServerLoaded", true) + end + + function OvertureYield.OnServerInvoke(_, Parent: Instance) + return Module._CountLibrariesIn(Parent) + end + + self._BindToTag("oHandled", function(LuaSourceContainer: LuaSourceContainer) + local RunsOn = LuaSourceContainer:GetAttribute("RunsOn") or "Empty" + + if LuaSourceContainer:IsA("LocalScript") then + if RunsOn == "Player" then + task.defer(Reparent, LuaSourceContainer, oStarterPlayerScripts) + elseif RunsOn == "Character" then + task.defer(Reparent, LuaSourceContainer, oStarterCharacterScripts) + else + warn(string.format([[Unknown RunsOn type "%s" on %s]], RunsOn, LuaSourceContainer:GetFullName())) + end + elseif LuaSourceContainer:IsA("Script") then + if RunsOn == "Player" then + warn(string.format([[Invalid RunsOn type "%s" on %s]], RunsOn, LuaSourceContainer:GetFullName())) + elseif RunsOn == "Character" then + task.defer(Reparent, LuaSourceContainer, StarterCharacterScripts) + + for _, Player in next, PlayerService:GetPlayers() do + if Player.Character then + LuaSourceContainer:Clone().Parent = Player.Character + end + end + else + warn(string.format([[Unknown RunsOn type "%s" on %s]], RunsOn, LuaSourceContainer:GetFullName())) + end + elseif LuaSourceContainer:IsA("ModuleScript") then + warn(string.format([[Invalid tag "oHandled" applied to %s]], LuaSourceContainer:GetFullName())) end end) - - function Module:LoadLibrary(Index) - if self.Libraries[Index] then - return require(self.Libraries[Index]) - else - assert(IsClient, "The library \"" .. Index .. "\" does not exist!") - printd("The client is yielding for the library \"" .. Index .. "\".") - - --/ Coroutine yielding has been temporarily replaced with BindableEvents due to Roblox issues. - - local BindableEvent = Instance.new("BindableEvent") - BindableEvent.Parent = script - - self.Libraries._WaitCache[BindableEvent] = Index - return require(BindableEvent.Event:Wait()) + + self._BindToTag("oLibrary", function(LuaSourceContainer: LuaSourceContainer) + if LuaSourceContainer:GetAttribute("ForceReplicate") then + LuaSourceContainer.Parent = Retrieve("Libraries", "Folder", script) end - end - - function Module:LoadLibraryOnClient(...) - if IsClient then - return self:LoadLibrary(...) + end) + + self._BindToTag("ForceReplicate", function(LuaSourceContainer: LuaSourceContainer) + LuaSourceContainer.Parent = Retrieve("Libraries", "Folder", script) + end) + + self._BindToTag("StarterPlayerScripts", function(LuaSourceContainer: LuaSourceContainer) + if LuaSourceContainer:IsA("LocalScript") then + task.defer(Reparent, LuaSourceContainer, oStarterPlayerScripts) + else + warn(string.format([[Invalid tag "StarterPlayerScripts" applied to %s]], LuaSourceContainer:GetFullName())) end - end - - function Module:LoadLibraryOnServer(...) - if IsServer then - return self:LoadLibrary(...) + end) + + self._BindToTag("StarterCharacterScripts", function(LuaSourceContainer: LuaSourceContainer) + if LuaSourceContainer:IsA("LocalScript") then + task.defer(Reparent, LuaSourceContainer, oStarterCharacterScripts) + elseif LuaSourceContainer:IsA("Script") then + task.defer(Reparent, LuaSourceContainer, StarterCharacterScripts) + + for _, Player in next, PlayerService:GetPlayers() do + if Player.Character then + LuaSourceContainer:Clone().Parent = Player.Character + end + end + else + warn(string.format([[Invalid tag "StarterCharacterScripts" applied to %s]], LuaSourceContainer:GetFullName())) end + end) +end + +function Module:YieldForLibrariesIn(Parent: Instance) + local ServerCount = OvertureYield:InvokeServer(Parent) + local ClientCount do + repeat + if ClientCount ~= nil then + Parent.DescendantAdded:Wait() + end + + ClientCount = self._CountLibrariesIn(Parent, true) + until ClientCount >= ServerCount end end -for SetName, SetClass in next, RetrievalSets do - local SetFolder = Retrieve(SetName, "Folder", ReplicatedStorage) - - Module["GetLocal" .. SetName] = function(self, ItemName) - return Retrieve(ItemName, SetClass, SetFolder) +function Module:LoadLibrary(Index: string) + if Libraries[Index] then + return require(Libraries[Index]) + else + assert(not RunService:IsServer(), "The library \"" .. Index .. "\" does not exist!") + + LibraryThreadCache[coroutine.running()] = Index + return require(coroutine.yield()) end - - Module["WaitFor" .. SetName] = function(self, ItemName) - return SetFolder:WaitForChild(ItemName, math.huge) +end + +function Module:LoadLibraryOnClient(...) + if RunService:IsClient() then + return self:LoadLibrary(...) end - - Module["Get" .. SetName] = function(self, ItemName) - local Item = SetFolder:FindFirstChild(ItemName) - if Item then return Item end - - if IsClient then - return SetFolder:WaitForChild(ItemName) - else - return self["GetLocal" .. SetName](self, ItemName) - end +end + +function Module:LoadLibraryOnServer(...) + if RunService:IsServer() then + return self:LoadLibrary(...) end end -if not IsClient then - BindToTag("StarterCharacterScripts", function(Object) - Object.Parent = StarterPlayer.StarterCharacterScripts - CollectionService:RemoveTag(Object, "StarterCharacterScripts") - end) - - BindToTag("StarterPlayerScripts", function(Object) - Object.Parent = StarterPlayer.StarterPlayerScripts - CollectionService:RemoveTag(Object, "StarterPlayerScripts") - end) +function Module:GetLocal(InstanceClass: string, InstanceName: string): Instance + return Retrieve(InstanceName, InstanceClass, (Retrieve("Local" .. InstanceClass, "Folder", script))) +end + +function Module:WaitFor(InstanceClass: string, InstanceName: string): Instance + return Retrieve(InstanceClass, "Folder", script, RunService:IsClient()):WaitForChild(InstanceName, math.huge) +end + +function Module:Get(InstanceClass: string, InstanceName: string): Instance + local SetFolder = Retrieve(InstanceClass, "Folder", script, RunService:IsClient()) + local Item = SetFolder:FindFirstChild(InstanceName) + + if Item then + return Item + elseif RunService:IsClient() then + return SetFolder:WaitForChild(InstanceName) + else + return Retrieve(InstanceName, InstanceClass, SetFolder) + end end +Module._BindToTag("oLibrary", function(Object) + Libraries[Object.Name] = Object + + for Thread, WantedName in next, LibraryThreadCache do + if Object.Name == WantedName then + LibraryThreadCache[Thread] = nil + task.spawn(Thread, Object) + end + end +end) + return Module From 2914474042b5623b85effe412f76e5a2414bf339 Mon Sep 17 00:00:00 2001 From: Ricardo Loureiro Date: Fri, 18 Feb 2022 00:17:38 +0000 Subject: [PATCH 2/5] Improve legacy support --- Overture.module.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Overture.module.lua b/Overture.module.lua index 0fe1a19..549c9f4 100644 --- a/Overture.module.lua +++ b/Overture.module.lua @@ -226,4 +226,29 @@ Module._BindToTag("oLibrary", function(Object) end end) +do --/ LEGACY SUPPORT + for _, SetClass in next, {"RemoteEvent", "RemoteFunction", "BindableEvent", "BindableFunction"} do + local SetFolder = Retrieve(SetClass, "Folder", ReplicatedStorage) + + Module["GetLocal" .. SetClass] = function(self, ItemName) + return Retrieve(ItemName, SetClass, SetFolder) + end + + Module["WaitFor" .. SetClass] = function(self, ItemName) + return SetFolder:WaitForChild(ItemName, math.huge) + end + + Module["Get" .. SetClass] = function(self, ItemName) + local Item = SetFolder:FindFirstChild(ItemName) + if Item then return Item end + + if RunService:IsClient() then + return SetFolder:WaitForChild(ItemName) + else + return self["GetLocal" .. SetClass](self, ItemName) + end + end + end +end + return Module From 798fe73fe0c93593df45ff4f8ed9e34fa70e8677 Mon Sep 17 00:00:00 2001 From: Ricardo Loureiro Date: Fri, 18 Feb 2022 00:18:19 +0000 Subject: [PATCH 3/5] Fix missing ReplicatedStorage reference --- Overture.module.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/Overture.module.lua b/Overture.module.lua index 549c9f4..9ec9388 100644 --- a/Overture.module.lua +++ b/Overture.module.lua @@ -4,6 +4,7 @@ local RunService = game:GetService("RunService") local PlayerService = game:GetService("Players") local StarterPlayer = game:GetService("StarterPlayer") +local ReplicatedStorage = game:GetService("ReplicatedStorage") local CollectionService = game:GetService("CollectionService") local OvertureYield = script:WaitForChild("OvertureYield") From a148a477ebd1fa43f238fb656e9ac94d394044bd Mon Sep 17 00:00:00 2001 From: Ricardo Loureiro Date: Fri, 18 Feb 2022 20:26:11 +0000 Subject: [PATCH 4/5] Remove deprecated functionality --- Overture.module.lua | 261 ++++++++++++++++++++++---------------------- 1 file changed, 133 insertions(+), 128 deletions(-) diff --git a/Overture.module.lua b/Overture.module.lua index 9ec9388..86f342b 100644 --- a/Overture.module.lua +++ b/Overture.module.lua @@ -6,10 +6,6 @@ local PlayerService = game:GetService("Players") local StarterPlayer = game:GetService("StarterPlayer") local ReplicatedStorage = game:GetService("ReplicatedStorage") local CollectionService = game:GetService("CollectionService") - -local OvertureYield = script:WaitForChild("OvertureYield") -local oStarterPlayerScripts = script:WaitForChild("StarterPlayerScripts"):: Folder -local oStarterCharacterScripts = script:WaitForChild("StarterCharacterScripts"):: Folder local StarterCharacterScripts = StarterPlayer:WaitForChild("StarterCharacterScripts"):: Folder local Module = {} @@ -18,15 +14,6 @@ local Libraries: {[string]: ModuleScript} = {} --// Functions -local function Reparent(Child, NewParent) - if Child:IsA("LocalScript") and not Child.Disabled then - Child:SetAttribute("EnableOnceReady", true) - Child.Disabled = true - end - - Child.Parent = NewParent -end - local function Retrieve(InstanceName: string, InstanceClass: string, InstanceParent: Instance, ForceWait: boolean?): Instance if ForceWait then return InstanceParent:WaitForChild(InstanceName) @@ -57,121 +44,6 @@ function Module._BindToTag(Tag: string, Function: (Instance) -> ()) return Module._BindFunction(Function, CollectionService:GetInstanceAddedSignal(Tag), CollectionService:GetTagged(Tag)) end -function Module._CountLibrariesIn(Parent: Instance, CountLocally: boolean?): number - local StoredCount = Parent:GetAttribute("LibrariesIn") - - if StoredCount then - return StoredCount - end - - if RunService:IsClient() and not CountLocally then - return OvertureYield:InvokeServer(Parent) - else - local Count = 0 - - for _, Descendant in next, Parent:GetDescendants() do - if Descendant:IsA("ModuleScript") then - Count += 1 - end - end - - if RunService:IsServer() then - Parent:SetAttribute("LibrariesIn", Count) - end - - return Count - end -end - -function Module:_LoadServer() - if script:GetAttribute("ServerLoaded") then - return warn("Attempted to load Overture multiple times.") - else - script:SetAttribute("ServerLoaded", true) - end - - function OvertureYield.OnServerInvoke(_, Parent: Instance) - return Module._CountLibrariesIn(Parent) - end - - self._BindToTag("oHandled", function(LuaSourceContainer: LuaSourceContainer) - local RunsOn = LuaSourceContainer:GetAttribute("RunsOn") or "Empty" - - if LuaSourceContainer:IsA("LocalScript") then - if RunsOn == "Player" then - task.defer(Reparent, LuaSourceContainer, oStarterPlayerScripts) - elseif RunsOn == "Character" then - task.defer(Reparent, LuaSourceContainer, oStarterCharacterScripts) - else - warn(string.format([[Unknown RunsOn type "%s" on %s]], RunsOn, LuaSourceContainer:GetFullName())) - end - elseif LuaSourceContainer:IsA("Script") then - if RunsOn == "Player" then - warn(string.format([[Invalid RunsOn type "%s" on %s]], RunsOn, LuaSourceContainer:GetFullName())) - elseif RunsOn == "Character" then - task.defer(Reparent, LuaSourceContainer, StarterCharacterScripts) - - for _, Player in next, PlayerService:GetPlayers() do - if Player.Character then - LuaSourceContainer:Clone().Parent = Player.Character - end - end - else - warn(string.format([[Unknown RunsOn type "%s" on %s]], RunsOn, LuaSourceContainer:GetFullName())) - end - elseif LuaSourceContainer:IsA("ModuleScript") then - warn(string.format([[Invalid tag "oHandled" applied to %s]], LuaSourceContainer:GetFullName())) - end - end) - - self._BindToTag("oLibrary", function(LuaSourceContainer: LuaSourceContainer) - if LuaSourceContainer:GetAttribute("ForceReplicate") then - LuaSourceContainer.Parent = Retrieve("Libraries", "Folder", script) - end - end) - - self._BindToTag("ForceReplicate", function(LuaSourceContainer: LuaSourceContainer) - LuaSourceContainer.Parent = Retrieve("Libraries", "Folder", script) - end) - - self._BindToTag("StarterPlayerScripts", function(LuaSourceContainer: LuaSourceContainer) - if LuaSourceContainer:IsA("LocalScript") then - task.defer(Reparent, LuaSourceContainer, oStarterPlayerScripts) - else - warn(string.format([[Invalid tag "StarterPlayerScripts" applied to %s]], LuaSourceContainer:GetFullName())) - end - end) - - self._BindToTag("StarterCharacterScripts", function(LuaSourceContainer: LuaSourceContainer) - if LuaSourceContainer:IsA("LocalScript") then - task.defer(Reparent, LuaSourceContainer, oStarterCharacterScripts) - elseif LuaSourceContainer:IsA("Script") then - task.defer(Reparent, LuaSourceContainer, StarterCharacterScripts) - - for _, Player in next, PlayerService:GetPlayers() do - if Player.Character then - LuaSourceContainer:Clone().Parent = Player.Character - end - end - else - warn(string.format([[Invalid tag "StarterCharacterScripts" applied to %s]], LuaSourceContainer:GetFullName())) - end - end) -end - -function Module:YieldForLibrariesIn(Parent: Instance) - local ServerCount = OvertureYield:InvokeServer(Parent) - local ClientCount do - repeat - if ClientCount ~= nil then - Parent.DescendantAdded:Wait() - end - - ClientCount = self._CountLibrariesIn(Parent, true) - until ClientCount >= ServerCount - end -end - function Module:LoadLibrary(Index: string) if Libraries[Index] then return require(Libraries[Index]) @@ -227,6 +99,135 @@ Module._BindToTag("oLibrary", function(Object) end end) +local function Initialize() + if RunService:IsServer() then + if script:GetAttribute("ServerHandled") then + return + end + + script:SetAttribute("ServerHandled", true) + + local oStarterPlayerScripts = Retrieve("StarterPlayerScripts", "Folder", script) + local oStarterCharacterScripts = Retrieve("StarterCharacterScripts", "Folder", script) + local function Reparent(Child, NewParent) + if Child:IsA("LocalScript") and not Child.Disabled then + Child:SetAttribute("EnableOnceReady", true) + Child.Disabled = true + end + + Child.Parent = Retrieve(NewParent, "Folder", script) + end + + Module._BindToTag("oHandled", function(LuaSourceContainer: Instance) + local RunsOn = LuaSourceContainer:GetAttribute("RunsOn") or "Empty" + + if LuaSourceContainer:IsA("LocalScript") then + if RunsOn == "Player" then + task.defer(Reparent, LuaSourceContainer, "StarterPlayerScripts") + elseif RunsOn == "Character" then + task.defer(Reparent, LuaSourceContainer, "StarterCharacterScripts") + else + warn(string.format([[Unknown RunsOn type "%s" on %s]], RunsOn, LuaSourceContainer:GetFullName())) + end + elseif LuaSourceContainer:IsA("Script") then + if RunsOn == "Player" then + warn(string.format([[Invalid RunsOn type "%s" on %s]], RunsOn, LuaSourceContainer:GetFullName())) + elseif RunsOn == "Character" then + LuaSourceContainer.Parent = StarterCharacterScripts + + for _, Player in next, PlayerService:GetPlayers() do + if Player.Character then + LuaSourceContainer:Clone().Parent = Player.Character + end + end + else + warn(string.format([[Unknown RunsOn type "%s" on %s]], RunsOn, LuaSourceContainer:GetFullName())) + end + elseif LuaSourceContainer:IsA("ModuleScript") then + warn(string.format([[Invalid tag "oHandled" applied to %s]], LuaSourceContainer:GetFullName())) + end + end) + + Module._BindToTag("oLibrary", function(LuaSourceContainer: Instance) + if LuaSourceContainer:GetAttribute("ForceReplicate") then + LuaSourceContainer.Parent = Retrieve("Libraries", "Folder", script) + end + end) + + Module._BindToTag("ForceReplicate", function(LuaSourceContainer: Instance) + LuaSourceContainer.Parent = Retrieve("Libraries", "Folder", script) + end) + + Module._BindToTag("StarterPlayerScripts", function(LuaSourceContainer: Instance) + if LuaSourceContainer:IsA("LocalScript") then + task.defer(Reparent, LuaSourceContainer, "StarterPlayerScripts") + else + warn(string.format([[Invalid tag "StarterPlayerScripts" applied to %s]], LuaSourceContainer:GetFullName())) + end + end) + + Module._BindToTag("StarterCharacterScripts", function(LuaSourceContainer: Instance) + if LuaSourceContainer:IsA("LocalScript") then + task.defer(Reparent, LuaSourceContainer, "StarterCharacterScripts") + elseif LuaSourceContainer:IsA("Script") then + LuaSourceContainer.Parent = StarterCharacterScripts + + for _, Player in next, PlayerService:GetPlayers() do + if Player.Character then + LuaSourceContainer:Clone().Parent = Player.Character + end + end + else + warn(string.format([[Invalid tag "StarterCharacterScripts" applied to %s]], LuaSourceContainer:GetFullName())) + end + end) + elseif RunService:IsClient() then + if script:GetAttribute("ClientHandled") then + return + end + + script:SetAttribute("ClientHandled", true) + + local Player = PlayerService.LocalPlayer + local PlayerScripts = Player:WaitForChild("PlayerScripts") + local oStarterPlayerScripts = script:WaitForChild("StarterPlayerScripts") + local oStarterCharacterScripts = script:WaitForChild("StarterCharacterScripts") + local function Reparent(Child, NewParent) + Child.Parent = NewParent + + if Child:IsA("LocalScript") and Child:GetAttribute("EnableOnceReady") then + Child.Disabled = false + end + end + + if script:FindFirstAncestorWhichIsA("PlayerGui") then + task.defer(Reparent, script:Clone(), PlayerScripts) + task.wait() + + script.Disabled = true + script:Destroy() + + return + end + + Module._BindFunction(function(Child: Instance) + task.defer(Reparent, Child, PlayerScripts) + end, oStarterPlayerScripts.ChildAdded, oStarterPlayerScripts:GetChildren()) + + Module._BindFunction(function(Child: Instance) + if Player.Character then + task.defer(Reparent, Child:Clone(), Player.Character) + end + end, oStarterCharacterScripts.ChildAdded, oStarterCharacterScripts:GetChildren()) + + Module._BindFunction(function(Character: Instance) + for _, Child in next, oStarterCharacterScripts:GetChildren() do + task.spawn(Reparent, Child:Clone(), Character) + end + end, Player.CharacterAdded, {Player.Character}) + end +end + do --/ LEGACY SUPPORT for _, SetClass in next, {"RemoteEvent", "RemoteFunction", "BindableEvent", "BindableFunction"} do local SetFolder = Retrieve(SetClass, "Folder", ReplicatedStorage) @@ -252,4 +253,8 @@ do --/ LEGACY SUPPORT end end +--// Triggers + +task.spawn(Initialize) + return Module From 07c7002985c8a16a397f0579781dbe73e6bbb7c4 Mon Sep 17 00:00:00 2001 From: Ricardo Loureiro Date: Fri, 18 Feb 2022 21:23:06 +0000 Subject: [PATCH 5/5] Fix "Requested module was required recursively" --- Overture.module.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Overture.module.lua b/Overture.module.lua index 86f342b..c560b9a 100644 --- a/Overture.module.lua +++ b/Overture.module.lua @@ -255,6 +255,6 @@ end --// Triggers -task.spawn(Initialize) +task.defer(Initialize) return Module