Skip to content

Commit

Permalink
Update init.lua
Browse files Browse the repository at this point in the history
Fixes issue with commands a types not registering if the client doesn't load on time

The client might load the "Types" and "Commands" Folder but not the children in them, This change ensures that any children added later get registered as well
  • Loading branch information
Benisgo authored Dec 28, 2024
1 parent 442f98f commit 3d9fb5f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Cmdr/CmdrClient/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,18 @@ end
-- "Only register when we aren't in studio because don't want to overwrite what the server portion did"
-- This is legacy code which predates Accurate Play Solo (which is now the only way to test in studio), this code will never run.
if RunService:IsServer() == false then
Cmdr.Registry:RegisterTypesIn(script:WaitForChild("Types"))
Cmdr.Registry:RegisterCommandsIn(script:WaitForChild("Commands"))
local TypesFolder = script:WaitForChild("Types") :: Folder
local CommandsFolder = script:WaitForChild("Commands") :: Folder

Cmdr.Registry:RegisterTypesIn(TypesFolder)
Cmdr.Registry:RegisterCommandsIn(CommandsFolder)

TypesFolder.ChildAdded:Connect(function(child: Instance)
require(child)(Cmdr.Registry)
end)
CommandsFolder.ChildAdded:Connect(function(child: Instance)
Cmdr.Registry:RegisterCommand(child)
end)
end

-- Hook up event listener
Expand Down

0 comments on commit 3d9fb5f

Please sign in to comment.