DataStore2 = require(game:GetService("ServerScriptService").DataStore2)
ServerStorage = game:GetService("ServerStorage")
Players = game:GetService("Players")
ReplicatedStorage = game.ReplicatedStorage
objectstore = ReplicatedStorage.bunker_obj_storage
default_omega_coins, default_likes, default_wins = 0, 0, 0
default_bunker_terrain_position_X = {
-69.073,-210.173,-136.738,133.657,
-45.073,-117.141,26.994,-45.073,-45.641
}
default_bunker_terrain_position_Y = {
67.784,67.784,67.784,67.784,3.047,
32.778,32.778,32.778,32.778
}
default_bunker_terrain_position_Z = {
-124.507,-50.947,-136.738,36.928,
71.493,71.635,72.202,-0.433,143.56
}
default_bunker_terrain_size_X = {
249.27,187.07,179.03,215.27,
145.27,1.135,1.135,145.27,144.135
}
default_bunker_terrain_size_Y = {
13.266,13.266,13.266,13.266,
4.266,56.746,56.746,56.746,56.746
}
default_bunker_terrain_size_Z = {
191.27,187.07,179.03,571.86,
145.27,142.716,143.851,1.419,1.135
}
default_bunker_terrain_rotation_X = {
0,0,0,0,0,0,0,0,0
}
default_bunker_terrain_rotation_Y = {
0,0,0,0,0,0,0,0,0
}
default_bunker_terrain_rotation_Z = {
0,0,0,0,0,0,0,0,0
}
---------------------------------------------------------------------------------------------------------------------------------
default_bunker_materials = {
"Grass","Grass","Grass","Grass",
"Mud","Rock","Rock","Rock","Rock","Rock"
}
DataStore2.Combine(
"TestA3", "Played", "Wins", "Ωmega Coins", "Likes", "bunker_name", "object_name",
"object_position_x", "object_position_y", "object_position_z",
"object_rotation_x", "object_rotation_y", "object_rotation_z",
"terrain_position_x", "terrain_position_y", "terrain_position_z",
"terrain_rotation_x", "terrain_rotation_y", "terrain_rotation_z",
"terrain_size_x", "terrain_size_y", "terrain_size_x",
"terrain_materials_x", "terrain_materials_y", "terrain_materials_z"
)
Players.PlayerAdded:Connect(function(Player)
winsStore = DataStore2("Wins", Player)
coinStore = DataStore2("Ωmega Coins", Player)
likesStore = DataStore2("Likes", Player)
bunkernameStore = DataStore2("bunker_name", Player)
objectnameStore = DataStore2("object_name", Player)
objectpositionStoreX = DataStore2("object_position_x", Player)
objectpositionStoreY = DataStore2("object_position_y", Player)
objectpositionStoreZ = DataStore2("object_position_z", Player)
objectrotationStoreX = DataStore2("object_rotation_x", Player)
objectrotationStoreY = DataStore2("object_rotation_y", Player)
objectrotationStoreZ = DataStore2("object_rotation_z", Player)
terrainpositionStoreX = DataStore2("terrain_position_x", Player)
terrainpositionStoreY = DataStore2("terrain_position_y", Player)
terrainpositionStoreZ = DataStore2("terrain_position_z", Player)
terrainrotationStoreX = DataStore2("terrain_rotation_x", Player)
terrainrotationStoreY = DataStore2("terrain_rotation_y", Player)
terrainrotationStoreZ = DataStore2("terrain_rotation_z", Player)
terrainsizeStoreX = DataStore2("terrain_size_x", Player)
terrainsizeStoreY = DataStore2("terrain_size_y", Player)
terrainsizeStoreZ = DataStore2("terrain_size_z", Player)
-- :Get()Variables
objectpositionGetX = objectpositionStoreX:Get({})
objectpositionGetY = objectpositionStoreY:Get({})
objectpositionGetZ = objectpositionStoreZ:Get({})
objectrotationGetX = objectrotationStoreX:Get({})
objectrotationGetY = objectrotationStoreY:Get({})
objectrotationGetZ = objectrotationStoreZ:Get({})
terrainpositionGetX = terrainpositionStoreX:Get(default_bunker_terrain_position_X)
terrainpositionGetY = terrainpositionStoreY:Get(default_bunker_terrain_position_Y)
terrainpositionGetZ = terrainpositionStoreZ:Get(default_bunker_terrain_position_Z)
terrainrotationGetX = terrainrotationStoreX:Get(default_bunker_terrain_rotation_X)
terrainrotationGetY = terrainrotationStoreY:Get(default_bunker_terrain_rotation_Y)
terrainrotationGetZ = terrainrotationStoreZ:Get(default_bunker_terrain_rotation_Z)
terrainsizeGetX = terrainsizeStoreX:Get(default_bunker_terrain_size_X)
terrainsizeGetY = terrainsizeStoreY:Get(default_bunker_terrain_size_Y)
terrainsizeGetZ = terrainsizeStoreZ:Get(default_bunker_terrain_size_Z)
terrainmaterialsStore = DataStore2("terrain_materials", Player)
terrainmaterialsGet = terrainmaterialsStore:Get(default_bunker_materials)
playedStore = DataStore2("Played", Player)
local played = Instance.new("BoolValue", Player)
played.Name = "played"
if playedStore:Get(false) then
played = true
else
played = false
end
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 = "O$"
omega_coins.Parent = leaderstats
end
local likes = Instance.new("IntValue") do
likes.Name = "Likes"
likes.Parent = leaderstats
end
leaderstats.Parent = Player
function save_to_model(player, bunkernameStore) ---------------------------------------------------- function start
local newMap = ServerStorage.empty_map:Clone() do
newMap.Name = Player.Name
local name = Instance.new("StringValue", newMap.params)
name.Name = "name"
if bunkernameStore then
name.Value = bunkernameStore
else
name.Value = "Bunker Construction Site"
end
local offset = Instance.new("NumberValue", newMap.params)
offset.Name = "offset"
--offset.Value = Player:WaitForChild("designated_bunker_position")
end
local terrain = newMap.terrain:WaitForChild("cubes")
print (terrainmaterialsStore)
print (terrainmaterialsGet)
for i, v in pairs(terrainmaterialsGet) do
print (i) print(v)
local Part = Instance.new("Part") do
Part.Name = v
Part.CFrame = CFrame.new(terrainpositionGetX, terrainpositionGetY, terrainpositionGetZ[i])
Part.Size = Vector3.new(terrainsizeGetX, terrainsizeGetY, terrainsizeGetZ[i])
Part.Orientation = Vector3.new(terrainrotationGetX, terrainrotationGetY, terrainrotationGetZ[i])
Part.Parent = terrain
Part.Anchored = true
Part.Transparency = 1
Part.CanCollide = false
newMap.Parent = game.Workspace.maps
end
for i, v in pairs (objectnameStore:Get({})) do
local obj = objectstore[v]:Clone()
obj.Position = CFrame.new(objectpositionGetX, objectpositionGetY, objectpositionGetZ[i])
obj.Orientation = Vector3.new(objectrotationGetX, objectrotationGetY, objectrotationGetZ[i])
end
end
end --------------------------------------------------------------------------------------------- function end
function model_to_save(new_name) ---------------------------------------------------------function start
local terrain = workspace.maps[Player.Name].terrain:WaitForChild("cubes"):GetChildren()
local mapobj = workspace.maps[Player.Name].obj:GetChildren()
print(new_name)
bunkernameStore:Set("MrGuyROBLOX's Dungeon")
local
terrainpositionX,
terrainpositionY,
terrainpositionZ,
terrainrotationX,
terrainrotationY,
terrainrotationZ,
terrainsizeX,
terrainsizeY,
terrainsizeZ,
terrainmaterials,
objectpositionX,
objectpositionY,
objectpositionZ,
objectrotationX,
objectrotationY,
objectrotationZ = {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}
for i = 1, #terrain do
local child = terrain[i]
if child:IsA("Part") then
terrainpositionX[i] = child.Position.X
terrainpositionY[i] = child.Position.Y
terrainpositionZ[i] = child.Position.Z
terrainrotationX[i] = child.Rotation.X
terrainrotationY[i] = child.Rotation.Y
terrainrotationZ[i] = child.Rotation.Z
terrainsizeX[i] = child.Size.X
terrainsizeY[i] = child.Size.Y
terrainsizeZ[i] = child.Size.Z
terrainmaterials[i] = child.name
end
end
for i = 1, #mapobj do
local objchild = mapobj[i]
if objchild:IsA("Model") then
local partchild = #mapobj[i]
for i = 1, #partchild do
if partchild:IsA("Part", "MeshPart") then
objectpositionX[i] = partchild[i].Position.X
objectpositionY[i] = partchild[i].Position.Y
objectpositionZ[i] = partchild[i].Position.Z
objectrotationX = partchild[i].Orientation.X
objectrotationY = partchild[i].Orientation.Y
objectrotationZ = partchild[i].Orientation.Z
end
end
end
end
terrainpositionStoreX:Set(terrainpositionX)
terrainpositionStoreY:Set(terrainpositionY)
terrainpositionStoreZ:Set(terrainpositionZ)
terrainrotationStoreX:Set(terrainrotationX)
terrainrotationStoreY:Set(terrainrotationY)
terrainrotationStoreZ:Set(terrainrotationZ)
terrainsizeStoreX:Set(terrainsizeX)
terrainsizeStoreY:Set(terrainsizeY)
terrainsizeStoreZ:Set(terrainsizeZ)
terrainmaterialsStore:Set(terrainmaterials)
objectpositionStoreX:Set(objectpositionX)
objectpositionStoreY:Set(objectpositionY)
objectpositionStoreZ:Set(objectpositionZ)
objectrotationStoreX:Set(objectrotationX)
objectrotationStoreY:Set(objectrotationY)
objectrotationStoreZ:Set(objectrotationZ)
if not played then
playedStore:Set(true)
end
end -------------------------------------------------------------------------------------------function end
ReplicatedStorage:WaitForChild("load_map").OnServerEvent:Connect(function(player)
save_to_model(player)
end)
ReplicatedStorage:WaitForChild("save_map").OnServerEvent:Connect(function(name)
model_to_save(name)
end)
end)
I’m trying to test a new account that just joined my game but when i change the key the save data stays the same. I tried using the test server thing in the test tab and it did act as if it was a new account but when i publish the game i’ll need to erase all the save data so i need to find a proper way.