Continuing off this topic (it died again for the billionth time): Error when trying to do DataStore2 stuff but what I am trying to do is save all my data which is listed in DataStore2.combine
in the script and firstly load the save for the bunker’s CFrame into part and also set the save to default bunker materials if the save is nil.
I get this error 20:33:16.091 - ServerScriptService.save_script:94: attempt to index nil with number when running this script
local ServerStorage = game.ServerStorage
local Workspace = game.Workspace
local Players = game.Players
local default_omega_coins = 0
local default_likes = 0
local default_wins = 0
local default_bunker_terrain_position = {CFrame.new(26.927, -33.383, -435.507), CFrame.new(26.927, 23.365, -572.788), CFrame.new(164.479, 23.365, -434.153),
CFrame.new(-110.625, 23.365, -435.236), CFrame.new(25.844, 23.365, -297.955)}
local default_bunker_terrain_size = {Vector3.new(277.27, 8.143, 277.27), Vector3.new(277.27, 108.309, 2.708),Vector3.new(2.166, 108.309, 274.562),Vector3.new(2.166, 108.309, 272.396),Vector3.new(275.104, 108.309, 2.166)}
local default_bunker_terrain_rotation = {CFrame.Angles(0,0,0), CFrame.Angles(0,0,0), CFrame.Angles(0,0,0),
CFrame.Angles(0,0,0), CFrame.Angles(0,0,0)}
local default_bunker_materials = {"Mud","Rock","Rock","Rock","Rock"}
local default_object_name = {}
local default_object_position = {}
local default_object_rotation = {}
DataStore2.Combine("main", "Wins", "Ωmega Coins", "Likes", "object_name", "object_position", "object_rotation", "terrain-position", "terrain_rotation", "terrain_size", "terrain_materials")
Players.PlayerAdded:Connect(function(plr)
winsStore = DataStore2("Wins", plr)
coinStore = DataStore2("Ωmega Coins", plr)
likesStore = DataStore2("Likes", plr)
objectnameStore = DataStore2("object_name", plr)
objectpositionStore = DataStore2("object_position", plr)
objectrotationStore = DataStore2("object_rotation", plr)
terrainpositionStore = DataStore2("terrain-position", plr)
terrainrotationStore = DataStore2("terrain_rotation", plr)
terrainsizeStore = DataStore2("terrain_size", plr)
terrainmaterialsStore = DataStore2("terrain_materials", plr)
local leaderstats = Instance.new("Folder",plr) ---leaderstats folder
leaderstats.Name = "leaderstats"
local wins = Instance.new("IntValue",leaderstats) --leaderstats
wins.Name = "Wins"
local omega_coins = Instance.new("IntValue",leaderstats)
omega_coins.Name = "Ωmega $"
local likes = Instance.new("IntValue",leaderstats)
likes.Name = "Likes"
if terrainpositionStore == nil then
terrainpositionStore = default_bunker_terrain_position
end
if terrainmaterialsStore == nil then
terrainmaterialsStore = default_bunker_materials
end
if terrainrotationStore == nil then
terrainrotationStore = default_bunker_terrain_rotation
end
if terrainsizeStore == nil then
terrainsizeStore = default_bunker_terrain_size
end
if objectnameStore == nil then
objectnameStore = default_object_name
end
if objectpositionStore == nil then
objectpositionStore = default_object_position
end
if objectrotationStore == nil then
objectrotationStore = default_object_rotation
end
if winsStore == nil then
terrainpositionStore = default_wins
end
if coinStore == nil then
coinStore = default_omega_coins
end
if likesStore == nil then
likesStore = default_likes
end
end)
function save_to_model(folder_name, target_location, CFrameoffset)
local newMap = ServerStorage.empty_map:Clone()
newMap.Name = folder_name
newMap.Parent = Workspace
local terrain = newMap.terrain:WaitForChild("cubes") -- FillBlock() is used on all parts in cubes.
for i, v in pairs(default_bunker_materials) do
local part = Instance.new("Part")
part.Name = v
-- new block:
part.CFrame = terrainpositionStore[i]
part.Size = default_bunker_terrain_size[i]
part.Parent = terrain
end
end
save_to_model("MrGuyROBLOX's Dungeon", game.Workspace.maps,0,0,0) -- test function
Also can someone keep an eye on this topic for once because I have made like 5 topics on DataStore2 that have just died and I really need to get this solved now.