How to delete save data+datastores? (DataStore2)

I need to test my game as if I’m a new player who has not played yet. Problem is that the game saved my data and saved the old version of the starter bunker. I have another datastore that I am using for testing purposes and I need to delete that as I’m going to use the main datastore and delete data after every test.

Btw when I mean save data i mean the data stored in the datastore and by datastore, I mean the key I use with the datastore.

3 Likes

I don’t really understand the question but there is a plugin which lets you edit your datastores although it is paid https://www.roblox.com/library/701506235/DataStore-Editor

2 Likes

As you are using DataStore2 you could try this:

For normal data stores you will have to use DataStore:RemoveAsync(Key) to remove any data stored under a data store:

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DATA STORE NAME HERE")
DataStore:RemoveAsync(Key)
1 Like

did "object_name", "object_x_position", "object_y_position", "object_z_position", "object_x_rotation", "object_y_rotation", "object_z_rotation", "terrain_x_position", "terrain_y_position", "terrain_z_position", "terrain_x_rotation", "terrain_y_rotation", "terrain_z_rotation", "terrain_x_size", "terrain_y_size", "terrain_z_size", "terrain_materials") DataStore:RemoveAsync(Ham) in the command bar on the server but it didn’t delete the data. It errored: 16:14:13.661 - Argument 1 missing or nil

Script btw

DataStore2 = require(game:GetService("ServerScriptService").DataStore2)
ServerStorage = game:GetService("ServerStorage")
Players = game:GetService("Players")
ReplicatedStorage = game.ReplicatedStorage

default_omega_coins, default_likes, default_wins = 0, 0, 0


default_bunker_terrain_x_position = {
	26.927,
	26.359,
	98.994,
	26.927,
	-45.141,
	179.03,
	215.27,
	249.27,
	187.07
}

default_bunker_terrain_y_position = {
	-33.383,
	-67.222,
	-67.222,
	-67.222,
	-67.222,
	13.266,
	13.266,
	13.266,
	13.266
}

default_bunker_terrain_z_position = {
	-540.507,
	-468.44,
	-539.798,
	-612.433,
	-540.365,
	332.22,
	571.86,
	191.27,
	396.15
}

default_bunker_terrain_x_size = {
	145.27,
	144.135,
	1.135,
	145.27,
	1.135,
}

default_bunker_terrain_y_size = {
	4.266,
	56.746,
	56.746,
	56.746,
	56.746
}

default_bunker_terrain_z_size = {
	145.27,
	1.135,
	143.851,
	1.419,
	142.716
}

default_bunker_terrain_x_rotation = {0,0,0,0,0,0,0,0,0}

default_bunker_terrain_y_rotation = {-90,0,-90,0,0,0,0,0,0}

default_bunker_terrain_z_rotation = {0,0,0,0,0,0,0,0,0}

default_bunker_materials = {
	"Mud",
	"Rock",
	"Rock",
	"Rock",
	"Rock",
	"Grass",
	"Grass",
	"Grass",
	"Grass"
}

DataStore2.Combine(
 "Ham", "Wins", "Ωmega Coins", "Likes", "bunker_name", "object_name",
 "object_x_position", "object_y_position", "object_z_position", "object_x_rotation", "object_y_rotation",
 "object_z_rotation", "terrain_x_position", "terrain_y_position", "terrain_z_position", "terrain_x_rotation",
 "terrain_y_rotation", "terrain_z_rotation", "terrain_x_size", "terrain_y_size", "terrain_z_size", "terrain_materials"
)

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)
	
	objectxpositionStore = DataStore2("object_x_position", Player)
	objectypositionStore = DataStore2("object_y_position", Player)
	objectzpositionStore = DataStore2("object_z_position", Player)

	
	objectxrotationStore = DataStore2("object_x_rotation", Player)
	objectyrotationStore = DataStore2("object_y_rotation", Player)
	objectzrotationStore = DataStore2("object_z_rotation", Player)

	
	terrainxpositionStore = DataStore2("terrain_x_position", Player)
	terrainypositionStore = DataStore2("terrain_y_position", Player)
	terrainzpositionStore = DataStore2("terrain_z_position", Player)
	
	terrainxrotationStore = DataStore2("terrain_x_rotation", Player)
	terrainyrotationStore = DataStore2("terrain_y_rotation", Player)
	terrainzrotationStore = DataStore2("terrain_z_rotation", Player)

	
	terrainxsizeStore = DataStore2("terrain_x_size", Player)
	terrainysizeStore = DataStore2("terrain_y_size", Player)
	terrainzsizeStore = DataStore2("terrain_z_size", Player)

	terrainmaterialsStore = DataStore2("terrain_materials", Player)
	
	local played = Instance.new("BoolValue", Player)
	played.Name = "played"
	if terrainmaterialsStore[1] then
		played = true
	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)
		if bunkernameStore then
			name.Value = bunkernameStore
			else
			name.Value = "Bunker Construction Site"
		end
		local offset = Instance.new("NumberValue", newMap.params)
		--offset.Value = Player:WaitForChild("designated_bunker_position")
	end
	local terrain = newMap.terrain:WaitForChild("cubes")
	for i, v in pairs(terrainmaterialsStore:Get(default_bunker_materials)) do
		print (i) print(v)
		local Part = Instance.new("Part") do
			Part.Name = v
			Part.CFrame = CFrame.new(
			 terrainxpositionStore:Get(default_bunker_terrain_x_position)[i],
			 terrainypositionStore:Get(default_bunker_terrain_y_position)[i],
			 terrainzpositionStore:Get(default_bunker_terrain_z_position)[i]
			)
			
			
			Part.Size = Vector3.new(
			 terrainxsizeStore:Get(default_bunker_terrain_x_size)[i],
			 terrainysizeStore:Get(default_bunker_terrain_y_size)[i],
			 terrainzsizeStore:Get(default_bunker_terrain_z_size)[i]
			)
			
			Part.Orientation = Vector3.new(
			 terrainxrotationStore:Get(default_bunker_terrain_x_rotation)[i],
			 terrainyrotationStore:Get(default_bunker_terrain_y_rotation)[i],
			 terrainzrotationStore:Get(default_bunker_terrain_z_rotation)[i]
			)
			
			
			Part.Parent = terrain
			Part.Anchored = true
			Part.Transparency = 1
			Part.CanCollide = false
			newMap.Parent = workspace.maps
		end
	end  --------------------------------------------------------------------------------------------- function end
	
		function model_to_save(new_name)	
		local terrain = workspace.maps[Player.Name]terrain:WaitForChild("cubes")
		bunkernameStore = new_name

for i = 1, #terrain do
		local child = terrain[i]
		
		if child:IsA("Part") then
			terrainxpositionStore[i] = child.Position.X
			terrainypositionStore[i] = child.Position.Y
			terrainzpositionStore[i] = child.Position.Z
			
			terrainxrotationStore[i] = child.Rotation.X
			terrainyrotationStore[i] = child.Rotation.Y
			terrainzrotationStore[i] = child.Rotation.Z
			
			
			terrainxsizeStore[i] = child.Size.X
			terrainysizeStore[i] = child.Size.Y
			terrainzsizeStore[i] = child.Size.Z
			
			
			terrainmaterialsStore[i] = child.Name
		end
	end

end
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)





1 Like