I’m trying to make a map swap script and it is partially working, the objects load but when I load terrain (the for loop) it doesn’t work.
ReplicatedStorage = game.ReplicatedStorage
loaded_map = script.Parent.loaded_map.Value
local_map_storage = ReplicatedStorage.local_map_storage
maps = game.Workspace.maps
maps_children = maps:GetChildren()
storage_children = local_map_storage:GetChildren()
Terrain = game.Workspace.Terrain
terrain_parts = maps[loaded_map]
cubes = terrain_parts.cubes:GetChildren()
cylinders = terrain_parts.cylinders:GetChildren()
spheres = terrain_parts.spheres:GetChildren()
local functions = {
load_map = function (area, spawn_area, transition, transition_name, transition_description, transition_colour)
print (area.." loaded")
ReplicatedStorage.load_area:FireServer(area, spawn_area)
maps[loaded_map].Parent = local_map_storage
loaded_map = area
local_map_storage[area].Parent = maps
for i = 1, #cubes do
local child = cubes[i]
if child:IsA("Part") then
game.Workspace.Terrain:FillBlock(game.Workspace.Part.CFrame, game.Workspace.Part.Size, Enum.Material.Grass)
end
return functions;
21:03:28.614 - Ωmega-BΩmb auto-recovery file was created
21:03:32.904 - Players.MrGuyROBLOX.PlayerScripts.local_functions:30: Expected ‘end’ (to close ‘do’ at line 23), got
21:03:32.904 - Requested module experienced an error while loading
21:03:32.904 - Stack Begin
21:03:32.905 - Script ‘Players.MrGuyROBLOX.PlayerGui.ScreenGui.main_menu.selection1.button1’, Line 3
21:03:32.905 - Stack End
21:03:32.968 - Requested module experienced an error while loading
21:03:32.969 - Stack Begin
21:03:32.969 - Script ‘Players.MrGuyROBLOX.PlayerScripts.boot_script’, Line 8
21:03:32.969 - Stack End
Ro-Defender has removed a total of 0 viruses and junk items from your games! (x2)