Datastore not resetting?

So I went to go make a new datastore because I had made some changes to the things I save however after testing it in an actual game (not studio) I realized that the data is still the same? So even though I changed it and it should be fresh it’s not?

local dataStore
if runService:IsStudio() then
	print("USING TESTING DATASTORE")
	dataStore = DataStoreService:GetDataStore("TestingV100")
else
	print("USING LIVE DATASTORE")
	dataStore = DataStoreService:GetDataStore("LiveV10")
end

The default gold in my game is 99k (for testing) however on LiveV9 I’m at 7.2k gold but putting it to LiveV10 it’s still 7.2k gold but it should be 99k so yeah idk what happened lol.

One possibility is that you might have accidentally saved the current value when changing datastores but I can’t be sure. In any case, you could perhaps clear the entry as if it never happened by using RemoveAsync (link here) and trying again.

Could we please see more of your script? All you are providing us with is the script you use to set the ‘datastore’ variable.

The script I use is from this Documentation - Roblox Creator Hub with some added stuff. Here’s the entire script though the setdata and getdata functions are what I added.

--[Services]--
local DataStoreService = game:GetService("DataStoreService")
local runService = game:GetService("RunService")

--[Data Stores]--
local dataStore
if runService:IsStudio() then
	print("USING TESTING DATASTORE")
	dataStore = DataStoreService:GetDataStore("TestingV100")
else
	print("USING LIVE DATASTORE")
	dataStore = DataStoreService:GetDataStore("LiveV10")
end

--[Remote Events / Functions]--
local dataEvent = game.ReplicatedStorage.Events:WaitForChild("data")

--[Variables]--
local HasPlayed = false
local PlayerStatManager = {}
local sessionData = {} --Table to hold player information for the current session
local autosaveTime = 60

-- Function that other scripts can call to change a player's stats
function PlayerStatManager:ChangeStat(player, statName, value)
	local playerUserId = "Player_" .. player.UserId
	assert(typeof(sessionData[playerUserId][statName]) == typeof(value), "ChangeStat error: types do not match")
	if typeof(sessionData[playerUserId][statName]) == "number" then
		sessionData[playerUserId][statName] = sessionData[playerUserId][statName] + value
		dataEvent:FireClient(player,PlayerStatManager:GetData(player))
	elseif typeof(sessionData[playerUserId][statName]) == "table" then
		sessionData[playerUserId][statName] = value
	else
		sessionData[playerUserId][statName] = value
	end
end

function PlayerStatManager:GetData(player, statName)
	local playerUserId = "Player_" .. player.UserId
	assert(sessionData[playerUserId], "GetData error: Data for " .. player.Name .. " does not exist.") --if data does not exist for player, then error

	if statName then
		local value = sessionData[playerUserId][statName]
		assert(value, "GetData error: Value does not exist for: ".. statName) --if there is no data for specified stat, then error

		return value -- if we specified a specific stat, then return the data for that stat
	else
		return sessionData[playerUserId] --if we didn't specify a specify stat, then return all the player's data
	end
end

function PlayerStatManager:setData(playerUserId)
	print("Saving")
	if sessionData[playerUserId] then
		local tries = 0	
		local success
		repeat
			tries = tries + 1
			success = pcall(function()
				dataStore:SetAsync(playerUserId, sessionData[playerUserId])
			end)
			if not success then wait(1) end
		until tries == 3 or success
		if not success then
			warn("Cannot save data for player!")
		end
	end	
end

-- Function to add player to the "sessionData" table
local function setupPlayerData(player)
	local playerUserId = "Player_" .. player.UserId
	local success, data = pcall(function()
		return dataStore:GetAsync(playerUserId)
	end)
	if success then
		if data then
			-- Data exists for this player
			HasPlayed = true
			print(player.Name.." has data")
			sessionData[playerUserId] = data
		else
			-- Data store is working, but no current data for this player
			print(player.Name.." doesn't have data")
			sessionData[playerUserId] = {
				newPlayer = "true", --will be used for inititating the tutorial if the player plays the tutorial this will beupdated to false
				isBanned = "false",
				banReason = "",
				dungeonLevel = 1,
				level = 1,
				xp = 0,
				gold = 99999,
				caps = 0,
				rep = 0,
				dimension = 0,
				power = 0,
				stamina = 0,
				agility = 0,
				inventory = {}, --items, materials, potions etc will be stored here
				equipped = {
					mainhand = "",
					offhand = "",
					head = "",
					body = "",
					neck = "",
					ring = "",
					accessory = "",
					pet = "",
				}, 
				Owned = {
					--Upgrades
					--Sodas
					["Peasent Pop"] = 1,
					--Customizations
					["Dirt"] = 1,
					["Busted"] = 1,
				},
				currentTavernCustomizations = { --current customizations (used when loading the players tavern
					currentFloorMaterial = "Grass",
					currentFloorColor = {R = 86,G = 66,B = 54},
					currentCounterMaterial = "CorrodedMetal",
					currentCounterColor = {R = 128, G = 73, B = 27},
				}
			}
		end
	else
		warn("Cannot access data store for player!")
	end
end

-- Function to save player's data
local function savePlayerData(playerUserId)
	if sessionData[playerUserId] then
		local tries = 0	
		local success
		repeat
			tries = tries + 1
			success = pcall(function()
				dataStore:SetAsync(playerUserId, sessionData[playerUserId])
			end)
			if not success then wait(1) end
		until tries == 3 or success
		if not success then
			warn("Cannot save data for player!")
		end
	end
end

-- Function to save player data on exit
local function saveOnExit(player)
	print("Saving")
	local playerUserId = "Player_" .. player.UserId
	savePlayerData(playerUserId)
end

-- Function to periodically save player data
local function autoSave()
	while wait(autosaveTime) do
		print("Auto Saving")
		for playerUserId, data in pairs(sessionData) do
			savePlayerData(playerUserId)
		end
	end
end

-- Start running "autoSave()" function in the background
spawn(autoSave)

-- Connect "setupPlayerData()" function to "PlayerAdded" event
game.Players.PlayerAdded:Connect(setupPlayerData)

-- Connect "saveOnExit()" function to "PlayerRemoving" event
game.Players.PlayerRemoving:Connect(saveOnExit)


return PlayerStatManager