Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Dispersal Script not working properly when distributing?

Asked by 7 years ago

This script disables the scripts in the game until all children are dispersed to their class, then enables them.

This is breaking other scripts in the game though. It might be that there are still things disabled which the scripts count on. Any idea on what changes I can make to this script to avoid that and fix my issue? If I wasn't specific enough I could let you access my game in Team Create to take a look at my scripts.

--Searches for all disabled scripts inside folder
local scripts = {}
function recursiveScriptSearch(inst)
    for _,v in pairs(inst:children()) do
        if v:IsA("Script") and v.Disabled then
            table.insert(scripts,v)
        end
        recursiveScriptSearch(v)
    end
end
recursiveScriptSearch(script.Parent)

for n,o in pairs(script.Parent.ReplicatedStorage:GetChildren()) do
    o.Parent = game.ReplicatedStorage
end
for n,o in pairs(script.Parent.Workspace:GetChildren()) do
    o.Parent = game.Workspace
end
for n,o in pairs(script.Parent.StarterGui:GetChildren()) do
    o.Parent = game.StarterGui
end
for n,o in pairs(script.Parent.StarterPack:GetChildren()) do
    o.Parent = game.StarterPack
end
for n,o in pairs(script.Parent.ServerStorage:GetChildren()) do
    o.Parent = game.ServerStorage
end
for n,o in pairs(script.Parent.ReplicatedFirst:GetChildren()) do
    o.Parent = game.ReplicatedFirst
end
for n,o in pairs(script.Parent.StarterPlayerScripts:GetChildren()) do
    o.Parent = game.StarterPlayer.StarterPlayerScripts
end
for n,o in pairs(script.Parent.StarterCharacterScripts:GetChildren()) do
    o.Parent = game.StarterPlayer.StarterCharacterScripts
end

for n,o in pairs(script.Parent.ServerScriptService:GetChildren()) do
    o.Parent = game.ServerScriptService
end
for n,o in pairs(script.Parent.Lighting:GetChildren()) do
    o.Parent = game.Lighting
end

--Go through all scripts and enable them
for _,v in pairs(scripts) do
    v.Disabled = false
end

print('Assets Loaded')
for n,o in pairs(game.Players:GetChildren()) do
game["Teleport Service"]:TeleportToPlaceInstance(game.PlaceId,game.JobId,o)
end


script.Parent:Destroy()

Answer this question