Error when trying to do DataStore2 stuff

Can this topic please not die before I solve the issue thanks.

I am trying to load the variable default_bunker_terrain_position with DataStore2:Get(default_bunker_terrain_position) but I get an error when the script gets to that line (48)

13:33:37.674 - ServerScriptService.save_script:48: attempt to call a nil value

Script:

local DataStore2 = require(1936396537) -- Don't mind this I will fix it later
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"}


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)
local winsStore = DataStore2("Wins", plr)
local coinStore = DataStore2("Ωmega Coins", plr)
local likesStore = DataStore2("Likes", plr)
local objectnameStore = DataStore2("object_name", plr)
local objectpositionStore = DataStore2("object_position", plr)
local objectrotationStore = DataStore2("object_rotation", plr)
local terrainpositionStore = DataStore2("terrain-position", plr)
local terrainrotationStore = DataStore2("terrain_rotation", plr)
local terrainsizeStore = DataStore2("terrain_size", plr)
local 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"
end)



function save_to_model(folder_name, target_location, CFrameoffset)
	DataStore2:Get(default_bunker_terrain_position) 
	
	local newMap = ServerStorage.empty_map:Clone()
	newMap.Name = folder_name
	newMap.Parent = Workspace
	local terrain = newMap.terrain:WaitForChild("cubes")
	
for i, v in pairs(default_bunker_materials) do
	local part = Instance.new("Part")
	part.Name = v

	-- new block:
	part.CFrame = default_bunker_terrain_position[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)

I just now thought maybe I there is a problem with my thing that sets the default value and that’s why it is nil but maybe not.

14 posts were merged into an existing topic: How to datastore2 more than 1 variable?