Combat tag punishment not working

so in my game if a player leaves when they are combat tagged they get a datastore value which is true and once they join again it will check if the value is true then proceed to not load in the saved tools and delete them but it dont work ofc

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Tools = ServerStorage.Tools
local CombatTagList = ServerStorage.PlayerList.CombatTagged
local DataStore2 = require(ServerStorage.Modules.DataStore2)

DataStore2.Combine("Data","Backpack")
DataStore2.Combine("Data","CombatLog")

function savetools (player,BackpackStore,bool)
	local Tools = {}
	
	if bool == true then
		if player.Character:FindFirstChildWhichIsA("Tool") and player.Character:FindFirstChildWhichIsA("Tool").CanBeDropped == true then
			table.insert(Tools,player.Character:FindFirstChildWhichIsA("Tool").Name)
		end

		for i,v in pairs(player.Backpack:GetChildren()) do
			if v.CanBeDropped == true then
				table.insert(Tools,v.Name)
			end
		end
	else
		for i,v in pairs(player.Backpack:GetChildren()) do
			if v.CanBeDropped == true then
				table.insert(Tools,v.Name)
			end
		end
	end
	
	BackpackStore:Set(Tools)
end

Players.PlayerRemoving:Connect(function(player)
	local CombatLogStore = DataStore2("CombatLog",player)

	if CombatTagList:FindFirstChild(player.Name) then
		CombatLogStore:Set(true)
		print(CombatLogStore:Get())
	end
end)

Players.PlayerAdded:Connect(function(player)
	local BackpackStore = DataStore2("Backpack",player)
	local CombatLogStore = DataStore2("CombatLog",player)
	
	print(BackpackStore:Get(),CombatLogStore:Get())
	
	if BackpackStore:Get() ~= nil then
		if CombatLogStore:Get() == true then
			print("clogged")
			BackpackStore:Set(nil)
			CombatLogStore:Set(false)
		else
			local PlayerTools = BackpackStore:Get()

			for i = 1,#PlayerTools do
				if Tools:FindFirstChild(PlayerTools[i],true) then
					Tools:FindFirstChild(PlayerTools[i],true):Clone().Parent = player.Backpack
				end
			end
		end
	end
	
	player.Backpack.ChildAdded:Connect(function(child)
		savetools(player,BackpackStore,true)
	end)
	
	player.Backpack.ChildRemoved:Connect(function(child)
		savetools(player,BackpackStore,false)
	end)
	
end)


unknown (8)
unknown (7)

sorry if im way off here

its giving you a success message which means whatever event the prints work from, well, work. could we see the datastore?

the prints are to see wat the combattagged value is which is each true or false so if they leave with combat tag it sets the value to true so next time they join if the value is true they lose their itmes

the datastore seems to have given a success message?

A strange scenario may take place:

  1. Datastore2 sees the player leaves, caches the datastores
  2. You set the true value to CombatLogStore
  3. Datastore2 saves the cached version to the actual datastores.

This is just an assumption though, perhaps after setting the true value try using Datastore2.SaveAll(player)?