DataStore pre-existing values issue

I have looked at videos and got it to work to an extent, it saves the data that is within the folder but I have noticed that when you scan one object and you leave, once you rejoin and it will make both values true even though the one you scanned should be the only value that is true and the other should remain false until you scan it.

local Players = game.Players
local DataStore = game:GetService("DataStoreService")
local playerDataStore = DataStore:GetDataStore("pkeData")
local Scannable = script.Scannable

local ScanabbleData = Scannable:Clone()

local function playerJoin(Player)
	ScanabbleData.Parent = Player
	
	local playerID = Player.UserId
	local pkeData = playerDataStore:GetAsync(playerID)
	if pkeData then
		for _, pkeScan in pairs(ScanabbleData:GetChildren()) do
			pkeScan.Value = pkeData
		end
	end
end

local function createTables(Player)
	local pkeStats = {}
	for _, pkeData in pairs(ScanabbleData:GetChildren()) do
		pkeStats[pkeData.Name] = pkeData.Value
	end
	return pkeStats
end

local function playerLeave(Player)
	local pkeStats = createTables(Player)
	local Success, Error = pcall(function()
		local playerID = Player.UserId
		playerDataStore:SetAsync(playerID, pkeStats)
	end)
	
	if not Success then
		warn('Scans not saved!')
	else
		print('Scans saved!')
	end
end

game.Players.PlayerAdded:Connect(playerJoin)
game.Players.PlayerRemoving:Connect(playerLeave)

It seems like a bug in your code where both values are set to true when a player rejoins after scanning one object. You might want to check how you are setting the values in the createTables() function and make sure that the values are properly reset when a player rejoins the game.

What do you mean checking how I am setting the values? the pkeStats[pkeData.Name] - pkeData.Value part? Since if so is there like a page or a forum that helps with figuring that out? Or do you have an example.