I made a simple map loading script for loading sections of a map so it can do wacky stuff, like going inside itself or not being able to see other parts of it through windows.
I wanted to know if this was a good way to do it? heres the script and video:
task.wait(3)
--This script is suppsoed to be flexible, and appliable to aother sections of the game
local Statuses = {
Load1 = {"Sec3"},
Load2 = {},
Load3 = {"Sec1"},
StartLoad = {"Sec3"} --The starting status of the map's loaded parts
}
local Sectors = {
Sec1 = script.Parent.Parent.Sec1,
Sec2 = script.Parent.Parent.Sec2,
Sec3 = script.Parent.Parent.Sec3
}
local function Load(VName)
for _, V in game.ServerStorage.Hideaway:GetChildren() do
V.Parent = script.Parent.Parent
end
for _, V in Statuses[VName] do
Sectors[V].Parent = game.ServerStorage.Hideaway
end
end
for _, V in script.Parent:GetChildren() do
if V:HasTag("LoadBlock") then
V.Touched:Connect(function()
Load(V.Name)
end)
end
end
Load("StartLoad") --ensuring that the map has its proper things loaded
This script works fine but i wanna know if theres better ways to do this