Ok I have been messing around with the script and I looked at the official DataStore2 forum posts How to use DataStore2 - Data Store caching and data loss prevention and I changed a few things but it still gets nil
from the DataStore2 variable even if I used :Get(--default value here)
Here is the script, I made sure to copy everything.
DataStore2 = require(game:GetService("ServerScriptService").DataStore2)
ServerStorage = game:GetService("ServerStorage")
Players = game:GetService("Players")
default_omega_coins, default_likes, default_wins = 0, 0, 0
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)
}
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)
}
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)
}
default_bunker_materials = {
"Mud",
"Rock",
"Rock",
"Rock",
"Rock"
}
default_object_name, default_object_position, 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(Player)
winsStore = DataStore2("Wins", Player)
coinStore = DataStore2("Ωmega Coins", Player)
likesStore = DataStore2("Likes", Player)
objectnameStore = DataStore2("object_name", Player)
objectpositionStore = DataStore2("object_position", Player)
objectrotationStore = DataStore2("object_rotation", Player)
terrainpositionStore = DataStore2("terrain-position", Player)
terrainrotationStore = DataStore2("terrain_rotation", Player)
terrainsizeStore = DataStore2("terrain_size", Player)
terrainmaterialsStore = DataStore2("terrain_materials", Player)
local leaderstats = Instance.new("Folder") do
leaderstats.Name = "leaderstats"
end
local wins = Instance.new("IntValue") do
wins.Name = "Wins"
wins.Parent = leaderstats
end
local omega_coins = Instance.new("IntValue") do
omega_coins.Name = "Ωmega $"
omega_coins.Parent = leaderstats
end
local likes = Instance.new("IntValue") do
likes.Name = "Likes"
likes.Parent = leaderstats
end
leaderstats.Parent = Player
end)
function save_to_model(folder_name, target_location, CFrameoffset, pos,size,rot,mat)
local newMap = ServerStorage.empty_map:Clone() do
newMap.Name = folder_name
end
local terrain = newMap.terrain:WaitForChild("cubes")
for i, v in pairs(terrainmaterialsStore:Get(default_bunker_materials)) do
local Part = Instance.new("Part") do
Part.Name = v
Part.CFrame = pos[i]
Part.Size = size[i]
Part.Parent = terrain
end
end
newMap.Parent = target_location
end
save_to_model("MrGuyROBLOX's Dungeon", game.Workspace.maps, 0, 0, 0, terrainpositionStore:Get(default_bunker_terrain_position), terrainsizeStore:Get(default_bunker_terrain_size), terrainrotationStore:Get(default_bunker_terrain_rotation,terrainmaterialsStore)) -- test function -- Line 90
script breaks at line 90 because it gets nil from :Get() even though if the value is nil it SHOULD use the value in the brackets.