So, since our game is huge, and the spawn itself is very laggy, we kinda need a way to optimize it more. We thought of separating areas into different games, like roblox lists in their optimization docs, but I’m not sure how to go about that.
Our game has a bunch of different scripts that get updated and bugfixed constantly, so we can’t just keep copying the scripts over to the games every time they get updated.
Would I have to make some sort of actual client and server framework that deploys itself when the game starts? Or is there any other easier ways to do this?
Apologies if this is the wrong category, but it’s mainly related to scripting, so hopefully it isn’t.
That’s not what I mean, I know about places and datastores, I meant how would I have a bunch of scripts, and constantly have all of them updated in each game?
You might be able to use ModuleScripts for it, To explain, you can get the AssetId of it by uploading it:
require(1234567890) -- Example of AssetId for ModuleScript
That way if you make changes, you can publish to Roblox, it will update on all Scripts that use it. (Do Note That this only works for ModuleScript, not Models, Folders, etc. Dont get mad at me for this because its stupid and i have had this happen before where People get made at me because of it.)
It looks like xGOA7x’s proposed solution might just work- I wrote a quick module that takes all of the folders that are named the same as they are in the game instance, and unpacks the contents inside into the actual services and folders.
Hierarchy if that didn't make any sense
I won’t mark it as the solution just yet, as I feel there may be a better way of doing this. This is the module:
local module = {}
local folder = script:WaitForChild('game')
local currentTime = tick()
warn('Loading...')
local msg = Instance.new('Message')
msg.Text = 'Loading'
msg.Parent = workspace
for _, v in ipairs(folder:GetChildren()) do
if game:FindFirstChild(v.Name) then
-- manually unpack StarterPlayer & character scripts, because the loop above can't check for it
for _, a in ipairs(v:GetChildren()) do
if a.Name == 'StarterPlayerScripts' then
for _, ac in ipairs(a:GetChildren()) do
ac.Parent = game:GetService('StarterPlayer'):WaitForChild('StarterPlayerScripts')
end
elseif a.Name == 'StarterCharacterScripts' then
for _, ac in ipairs(a:GetChildren()) do
ac.Parent = game:GetService('StarterPlayer'):WaitForChild('StarterCharacterScripts')
end
else
a.Parent = game:FindFirstChild(v.Name)
end
end
end
end
local timeTook = tick()-currentTime
warn('Loaded, took '.. tick()-currentTime..'s (rounded: '.. math.round(timeTook)..'s)')
msg:Destroy()
return module
I also looked at Packages, but I don’t think they will work for this use case. Unless scripts can also be packages.
I believe if you put a module inside a model, then name it to MainModule, folders will work. Haven’t tried this, I found it from here.
Okay, I’ve stuck with the solution above for a couple of weeks, but it still doesn’t really work very well. I can’t override core scripts with it, like the player module, since they’re processed on the client.
Also, it’s really weird to be editing a model instead of the default services. Anyone have any ideas?
I think packages are the closest you can get without a ton of extra work. It’s what I tend to use because it makes syncing the scripts easier between places. I really only have scripts as packages.
I don’t quite understand what makes them difficult to work with since you just save them and then update them and otherwise they act as normal scripts. Though I might not entirely understand the problem.